reset password
Author Message
calikidd
Posts: 41
Posted 09:03 Apr 09, 2009 |

I'm trying to sort a Two Dimensional Array. There a lot of different ways to sort. Does anyone have an idea which is best and easiest to code for this lab. Bubble, Insertion, etc.?

ckolodin
Posts: 6
Posted 01:36 Apr 10, 2009 |

the Arrays class has a built in sort method for arrays! I hear it uses quicksort. (Anyone know for sure?)

so if you take each element of a 2D array out and put it in a 1D array you can uses Arrays.sort() on the 1D array and then put the ordered elements back into the 2D array

Redalb
Posts: 22
Posted 03:05 Apr 10, 2009 |

This is how I did it.

I searched online for how this is generally done. I got an array(<--har har, get it?) of answers that didnt really seem to satisfy me. Some using comparators in java.util.arrays and all sorts of other stuff.

I just decided to make my own.

I had the method in here but the formating would change every time i edited to something else, I attached a file with it instead.

Please do not post solutions to homework problems here.

Last edited by mhajianpour at 10:47 Apr 10, 2009.
mhajianpour
Posts: 20
Posted 09:51 Apr 10, 2009 |

Good job. Please don't post full solutions to the questions on the labs. Try to guide, not give away. Thanks.

Chris,
That's a very intuitive way of doing the sort, good work.

--
Mahan Hajianpour

Harshil
Posts: 18
Posted 22:13 Apr 10, 2009 |
calikidd wrote:

I'm trying to sort a Two Dimensional Array. There a lot of different ways to sort. Does anyone have an idea which is best and easiest to code for this lab. Bubble, Insertion, etc.?

 

Bubble Sort is easy with compare to others