The tool needs the file sorted in a specific order and this one is not
Most downstream tools require coordinate-sorted, indexed BAM; a few (mate-fixing, some counters) require name-sorted instead. Files come out of an aligner in neither order, and the header's SO: tag is what tools check.
Sort into the order that step actually needs — samtools sort for coordinate, samtools sort -n for name — then index if it is coordinate-sorted. Sorting twice in a pipeline is a common waste; check what each step requires before adding another sort.