in reply to sort messes up data

After executing the sort the data gets messed up, the debugger looses track of it.

Basic debugging checklist teaches use warnings which warn you

Use of reference "ARRAY(0x3f9adc)" as array index at - line 12. Use of reference "ARRAY(0x3f9bec)" as array index at - line 12. Use of uninitialized value in numeric comparison (<=>) at - line 12. Use of uninitialized value in numeric comparison (<=>) at - line 12.

Creating huge arrays can lead to swapping