I have a long list of string values I am trying to sort in a grid. Initially, the default sort algorithm was used for the entire grid. However, I ended up having to rewrite the sorting for the grid because a few columns required special sorting and the grid does not allow custom sorting for specific columns. The column in question here did not require special sorting, so I just used CompareTo:
Public Function Compare(ByVal p1 as MyObj, ByVal p2 as MyObj) As Integer
Return p1.Description.CompareTo(p2.Description)
End Function
Comparing the default grid sort method and the one I'm now using with CompareTo, I get the exact same results. However, the sort results from a direct database query differ (where the database results are correct according to what I think they should be).
Here are three examples of what I believe are incorrect sort results:
Example 1
Sort Result:
- TEST- A/A MY TEST
- TEST1000 A TEST
- TEST1000 TEST
- TESTR A TEST
- TEST-B/A MY TEST
Expected Result:
- TEST- A/A MY TEST
- TEST-B/A MY TEST
- TEST1000 A TEST
- TEST1000 TEST
- TESTR A TEST
Example 2
Sort Result:
- TEST- A TEST
- TEST ME
- TEST-#1 A
- TEST-#1 B
Expected Result:
- TEST ME
- TEST- A TEST
- TEST-#1 A
- TEST-#1 B
Example 3
Sort Result:
- LOUISE TEST 1
- LOUISE TEST 2
- LOUIS- TEST 1
Expected Result:
- LOUIS- TEST 1
- LOUISE TEST 1
- LOUISE TEST 2
Has anyone run across this before or have any ideas what could be going on here?