File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
does this sort an array of integers?
Joined: Dec 04, 2005
Mar 30, 2006 10:48:00
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)
for(int index=0; index<list.length-1; index++)
for(int scan=index+1; scan<list.length; scan++)
if(list[scan].compareTo(list[min] < 0)
temp = list[min];
author and iconoclast
Joined: Jul 08, 2003
Mar 30, 2006 10:59:00
No, only objects. But why not use java.util.Arrays.sort()?
[Jess in Action]
Joined: Jan 17, 2006
Mar 30, 2006 16:54:00
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?
More Array sorting trouble
im trying to sort my program with insertionSort and selectionSort
help with sort code
method overloading in sort program
cannot resolve a symbol with a method.
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014