This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes Flexibly sorting primitive arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Flexibly sorting primitive arrays" Watch "Flexibly sorting primitive arrays" New topic

Flexibly sorting primitive arrays

steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 862
Is there a way to sort an int[] in an order other than ascending or descending. For example if the array had values 1-9, maybe soring in even/odd order (2,4,6,8,1,3,5,7,9). With Object[] you could do this with a Comparator. Can it be done with primitives without first converting the primitive array to an object array? - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
Have you tried it with a Comparator? I think autoboxing might help you out here. If that doesn't work you're stuck rolling your own.
I agree. Here's the link:
subject: Flexibly sorting primitive arrays
jQuery in Action, 3rd edition