sjbarag / brs

An interpreter for the BrightScript language that runs on non-Roku platforms.
MIT License
113 stars 43 forks source link

Sorting Array of numbers actually sorts in alphabetical order, instead of by value #591

Closed markwpearce closed 3 years ago

markwpearce commented 3 years ago

ifArray.Sort() method does not properly sort an array of integers. Instead of sorting in ascending value, instead it sorts the values as if they were strings, so 10 comes before 9, etc.

In the BRS command line:

brs> a = [3, 2, 1, 11]
brs> a.sort()
brs> ?a
<Component: roArray> =
[
    1
    11
    2
    3
]
brs>

But running on an actual Roku:

Brightscript Debugger> 
a = [3, 2, 1, 11]

Brightscript Debugger> 
a.sort()

Brightscript Debugger> 
?a
<Component: roArray> =
[
    1
    2
    3
    11
]

Brightscript Debugger>