Sorting text as numbers

Posts   
 
    
Anderskj1
User
Posts: 33
Joined: 11-Jan-2005
# Posted on: 30-Jun-2005 12:41:14   

Hi

We have a small problem with sorting some orders in our system. The orders unique identifer is a string field in the database.

1001 1002

And so on.

But when sorting the rows a (of course) sorted as strings which results in obscure textuel sortings as:

1001 200 90 (textual sort)

Which if course is not what we need. Is there a way to do this correct with LLBL? If not. How is the best way to get them sorted correct when i have a xxxxCollection sorted the wrong way?

Thanks in regards Anders

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 30-Jun-2005 13:05:34   

Write a simple IComparer class which you pass into the collection.Sort() method. The IComparer class should cast the values to int and return the compare of those. That should sort the values in the collection.

Frans Bouma | Lead developer LLBLGen Pro