File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes sorting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "sorting" Watch "sorting" New topic
Author

sorting

vasu kasukurthi
Greenhorn

Joined: Dec 14, 2009
Posts: 9
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

Joined: Oct 13, 2005
Posts: 39865
    
  28
Have you tried a Comparator? Have you written down on paper what the rules are to provide a "natural ordering"?
Patricia Samuel
Ranch Hand

Joined: Sep 12, 2007
Posts: 300
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.....
 
Don't get me started about those stupid light bulbs.
 
subject: sorting