Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sorting

 
vasu kasukurthi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have data in a file like
1,2,3,1WM,1WM5,1WM2,15MN,15MN10,9MN,9MN1,
11XL,11XL2,5XX,1MN,1MN2,1LM

i have to read data and need to sort like the following
1,1LM,1MN,1MN2,1WM,1WM5,2,3,5XX,9MN,9MN1,11XL,11XL2,15MN,15MN10

Please can any one help me.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50241
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried a Comparator? Have you written down on paper what the rules are to provide a "natural ordering"?
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you have to use Comparator for that purpose and the logic could be like you have to get substring and then have to sort those parts.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic