File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sorting of elements in an array

 
yekkala krishna
Ranch Hand
Posts: 105
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi this is Y.Rama Krishna.i have small problem regarding sorting of an array.
i have an array like :
int a[]={1,2,3,1,2,3,1,2,3,1,2,3};
This array i have to sort like {1,1,1,1,2,2,2,2,3,3,3,3}
How i can sort the elements in this order.
Thanks in advance.
 
Rob Spoor
Sheriff
Pie
Posts: 20381
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this a homework assignment or not?

If not, check class java.util.Arrays. It has some methods for sorting different types of arrays.
 
Stuart Smith
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use modulo to determine if a number is odd or even take a look a http://www.javaranch.com/evenOrOdd.jsp

Having trouble with arrays my self so can't offer any help with that part.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47270
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They ought to be teaching you about sorting. Try here or here.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic