The basic problem here is that the sort functionality of the Listview control is treating the values as strings. If you consider the values to be strings, "2" is certainly a higher value than "15", simply because the "2" (ASCII code 50) is higher than the "1" (ASCII code 49). I imagine things might be more complex if dealing with Unicode.
This confusion between numbers and strings has been around for many years, and there are various ways in which one might work around it. These include (but are not limited to):
- If possible, use your own code to do the sort, converting all values either to numbers, or two strings of the same length (such as "00015" and "00002"). I don't know whether the Listview control provides any way to customise the sorting, or not.
- If the Listview control supports it, store the values in it as numbers rather than strings.
- Add a hidden column and sort on that. In other words, if supported, add another column which is not possible to the user, and copy the values from the problematic column in a "sortable" format. For example, with leading zeroes as described in the first bullet point.
- Sort the data before placing it in the listview. If it's coming form a database, this might mean including an ORDER BY clause in your SQL. If not, you might need to sort an array first, or simply change the order in which you add them to the ListView.
.