• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Flexibly sorting primitive arrays

 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bill Cruise
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic