A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
OCM Java EE 6 Enterprise Architect Exam Guide
this week in the
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
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
subject: does this sort an array of integers?
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.
More Array sorting trouble
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014