Let\'s say I have an unsorted array from 1 to 10, as shown below...
a = ["3", "5", "8", "4", "1", "2",
The reason for this behavior is that you have an array of strings and the sort that is being applied is string-based. To get the proper, numeric, sorting you have to convert the strings to numbers or just keep them as numbers in the first place. Is there a reason that your array is being populate with strings like this:
a = ["3", "5", "8", "4", "1", "2", "9", "10", "7", "6"]
Rather than numbers like this:
a = [3, 5, 8, 4, 1, 2, 9, 1, 7, 6]
?