File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes does this sort an array of integers? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "does this sort an array of integers?" Watch "does this sort an array of integers?" New topic

does this sort an array of integers?

alaina peeler

Joined: Dec 04, 2005
Posts: 29
im using selectionSort to sort an array of integers that i will create later. For example int a[MAX]; <---this will be my array. I know this sorts an array of objects, but what about integers?

public static void selectionSort(Comparable[] list)
int min;
Comparable temp;

for(int index=0; index<list.length-1; index++)
{ min=index;
for(int scan=index+1; scan<list.length; scan++)
if(list[scan].compareTo(list[min] < 0)

temp = list[min];
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

No, only objects. But why not use java.util.Arrays.sort()?

[Jess in Action][AskingGoodQuestions]
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
Have tested it with an int[]? If so, what types of errors are you getting?

Ernest Friedman-Hill: ...But why not use java.util.Arrays.sort()?

I'm guessing this is an assignment of some sort (bad pun intended) about implementing sorting algorithms.

Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
I agree. Here's the link:
subject: does this sort an array of integers?
It's not a secret anymore!