Why does JavaScript sort 10 before 2 in my list of session lengths?
TechnologyThe sample session lengths are the numbers 2, 10 and 3. My page calls `lengths.sort()` and displays 10, 2, 3. I checked the input: these are number values, not strings copied out of form fields.
I expected a numerical order and started looking for a conversion bug. MDN says the default sort compares string representations; it also notes that sort changes the original array. MDN's sort reference
What's the smallest sensible correction here? The sorted list is for display, while another part of the exercise still needs the original sequence in which the sessions were entered.