This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Help with sort function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with sort function" Watch "Help with sort function" New topic

Help with sort function

Joel Allison

Joined: Nov 17, 2009
Posts: 9
I'm writing a program that is supposed to sort data by population, and by alphabetical order. I can't get it to work though, I think it is specifically my sort functions.


I tried to walkthrough these, and I think something is wrong with them. I don't think they fully sort my list, any help would be greatly appreciated.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 36599
What sort algorithm are you using?
Amarnath Pandi

Joined: Dec 04, 2009
Posts: 9
Could you explain little more about the code.

in sortByPopulation,
You are comparing b[] but only swapping a and b. is it OK? In this case b[] values will not be changed right?
What is in a[] and b[]?

I agree. Here's the link:
subject: Help with sort function
Similar Threads
new to java
'class' or 'interface' expected
I am new to Java programming
Fill the code
Exception in thread