Playing with strings

You appear to have shoehorned the determination of the width into the sorting subroutine... that feels wrong :-(