Results 21 to 26 of 26
- 02-08-2012, 01:34 AM #21
- 02-08-2012, 01:42 AM #22
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
- 02-08-2012, 02:13 AM #23
Re: Sort through array, finding pairs.
Yes you would need to pass all the arrays that you want to keep in synch so their contents can be moved in parallel.
- 02-08-2012, 02:18 AM #24
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
Re: Sort through array, finding pairs.
I did this and so far it's working. Is there anything blatantly wrong that will come back to bite me in the ass?
Java Code:public static void bubblesort(int[] a, String[] b) { boolean swapped = true; int temp; String tempb; while(swapped) { swapped=false; for(int i=0; i<a.length-1;i++) { if(a[i] > a[i+1]) { temp = a[i]; tempb = b[i]; a[i] = a[i+1]; b[i] = b[i+1]; a[i+1] = temp; b[i+1] = tempb; swapped = true; } } } System.out.println("Zips sorted:" + Arrays.toString(a)); for(int bl=0;bl<b.length;bl++) { System.out.println(b[bl]); } }
- 02-08-2012, 02:20 AM #25
Re: Sort through array, finding pairs.
If it works, it's probably fine.
- 02-08-2012, 03:29 AM #26
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
Similar Threads
-
Need help with Array.sort()
By Kinney.j in forum New To JavaReplies: 1Last Post: 10-16-2011, 06:51 AM -
Algorithm for finding max and min in an array.
By Shyamz1 in forum New To JavaReplies: 4Last Post: 10-04-2011, 10:45 PM -
Finding the Mode in An Array
By carlodelmundo in forum New To JavaReplies: 23Last Post: 10-31-2010, 12:44 PM -
sort array >> need help
By hongi in forum New To JavaReplies: 4Last Post: 04-25-2010, 09:37 PM -
Finding a the max value of the array using a for loop
By soccer_kid_6 in forum New To JavaReplies: 1Last Post: 04-11-2010, 11:25 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks