my dog learned polymorphism*
The moose likes Beginning Java and the fly likes what is the best method to sort strings in real time or off line ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is the best method to sort strings in real time or off line ? " Watch "what is the best method to sort strings in real time or off line ? " New topic
Author

what is the best method to sort strings in real time or off line ?

Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
Hello all
i have program that needs to collect strings from different kinds of resources.
now the strings can be duplicated and i need to sort them i wander what will be the best way
to do that or to divide the job to 2 phases in which first phase will collect the data without checking duplication
just write then to file and in the second phase i will use unix "sort -u" on the files and then the program will handle the
new information
or
do it all in one phase and every string will be kept into map and then every time the program collects new string it will check agents the map
to see if it already there .
in term of speed what will be the best solution ?
Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37923
    
  22
Putting them into a Map or Set would work; there are Set implementations which sort automatically.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is the best method to sort strings in real time or off line ?
 
Similar Threads
about Garbage Collector logic.
how to Initialize an ArrayList in a constructor with no parameters?
System.out.print vs. String concantenation
Problem with handling huge data structures
Help with returning one string from three methods of type string?