Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Sorting Strings
What is the best way to sort an array of strings, by that i mean, sort each
individual string alphabetically, and maybe then have two arrays, one with
the sorted word and the other with the original word, so that they can be
cross referenced. At the moment I am considering using mergesort, is this a
good idea, or if there something more practical? I am writing a class which
finds anagrams from a large set of words.

Cheers

Paul



Report this thread to moderator Post Follow-up to this message
Old Post
Paul Morrison
10-28-04 01:58 PM


Re: Sorting Strings
On 28-10-2004 14:15, Paul Morrison wrote:
> What is the best way to sort an array of strings, by that i mean, sort eac
h
> individual string alphabetically, and maybe then have two arrays, one with
> the sorted word and the other with the original word, so that they can be
> cross referenced. At the moment I am considering using mergesort, is this 
a
> good idea, or if there something more practical? I am writing a class whic
h
> finds anagrams from a large set of words.
>
> Cheers
>
> Paul

See the help on Arrays.sort(Object[] a). This might help you.

Paul.

Report this thread to moderator Post Follow-up to this message
Old Post
Paul H. van Rossem
10-28-04 01:58 PM


Re: Sorting Strings
"Paul Morrison" <pm42@kent.ac.uk> wrote in message
news:clqnt7$qbu$1@athena.ukc.ac.uk...
> What is the best way to sort an array of strings, by that i mean, sort
each
> individual string alphabetically, and maybe then have two arrays, one with
> the sorted word and the other with the original word, so that they can be
> cross referenced. At the moment I am considering using mergesort, is this
a
> good idea, or if there something more practical? I am writing a class
which
> finds anagrams from a large set of words.
>

If you mean sort array: {"bag", "ape", "can"}
to: {"abg", "aep", "acn"}

then iterate the array doing this on each element:

char[] chs = myString.toCharArray()

Arrays.sort(chs);

newArray[i] = new String(chs);

--
Mike W



Report this thread to moderator Post Follow-up to this message
Old Post
VisionSet
10-28-04 01:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:08 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.