Click here to Skip to main content
15,749,352 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
OK basically i have a members club full of members and when i want to get all their names back
i use this code but what i really want to do is get them all back alphabetically, and i cant use the help of a java lib i have to use my own sort method. And before any one sends me links to java docs i have already tried but cannot figure it out.

 * List names.
public void listNames() {
    for (int i = 0; i < members.size(); i++) {
        Member member = members.get(i);
        StdOut.println(i + ":" + member.getName());
Updated 25-Apr-14 1:10am
[no name] 24-Apr-14 7:48am    
Okay so what is stopping you from reading the documentation for the ArrayList class?
paul power 24-Apr-14 7:54am    
I have tried every thing to sort this out but i don't now what way to go about it
BupeChombaDerrick 25-Apr-14 13:03pm    
You can try heapsort, check my updated solution :)

You should be able to adopt the code when you copy it for the homework.

Your teacher can see if it's your code or another ones.

Please check the API:[^]
Share this answer
paul power 24-Apr-14 11:09am    
Still stuck on this can any one even help with the first few lines
TorstenH. 25-Apr-14 6:42am    
What is the problem? Please ask specific and use "improve question" for it.
Try this

public static void sortStringExchange( String  x [ ] ){
             Arrays.sort(x, new Comparator<string>() {
                public int compare(String s1, String s2) {
                return s1.compareTo(s2);

Well try heapsort[^][^]

Hope this helps :)

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900