SortedList - Comparer help

  • Thread starter Thread starter sho_nuff
  • Start date Start date
S

sho_nuff

Hello all,

I have a sorted list that contains items:

foo1
foo2
foo3
foo10
foo11
foo12

I want them to be displayed as above, but when i retrieve from my
sorted list they come back as:

foo1
foo10
foo11
foo12
foo2
foo3

Is there a Comparer in C# that will do the kind of sort that i want,
or do i have to write my own?

Thanks
SN
 
SN,

You will have to write your own. What you will have to do is chop off
the portion that is numeric on the two items being compared. When you do
that, take the text part, and do a comparison. If they are equal, then
convert the number portions and return the result when comparing the
numbers.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top