Alternative content
samtools view -bS file.sam | samtools sort - file_sorted samtools index test_sorted.bam test_sorted.bai