in reply to How to Sort Numerical String

Is this homework? See sort

update: also you're not sorting based on N at all. If you did, your sorted list would start with '1 - foo - xxx', '1 - bar - aaa', '1 - bar - atc' (in whatever order).

You appear to be splitting the array into parts based on some unknown criteria, then sorting those parts based on N, and then recombining the parts.