Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 28th, 2004, 2:48 AM   #1
sunnylearns
Newbie
 
Join Date: Jun 2004
Posts: 1
Rep Power: 0 sunnylearns is on a distinguished road
A generic Sorter
sunnylearns is offline   Reply With Quote
Old Jul 28th, 2004, 4:06 AM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
And what a great tutorial that was
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jul 28th, 2004, 6:03 AM   #3
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Quick sort is fun Not so easy to work with though if you want a stable sort of course... though it is possible if I recall correctly.... actually now that I think about it, it really is not difficult to implement.

Shell sorts are just... nasty... I hate them, and merge sort, well they are alright, but I do not like the way the recurse
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Jul 28th, 2004, 8:19 AM   #4
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
I'm guessing he's looking for a sort method. Since this is not a tutorial, it has been moved to the Java section from the Java tutorial section.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Jul 28th, 2004, 9:38 AM   #5
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
looks to me that he just wants us to do it for him.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Jul 28th, 2004, 9:47 PM   #6
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
No idea what this is all about... But gotta love the recursion; hence, the name.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Jul 29th, 2004, 1:47 AM   #7
ASBands
Newbie
 
Join Date: Jul 2004
Posts: 1
Rep Power: 0 ASBands is on a distinguished road
Bubble Sort all the way!

Just kidding!

But here are two methods for bubble sort with strings...pretty generic...

static void BubbleSortRecurse(String[] s){
 for (int i = 0; i < s.length - 1; i++){
 	if (s[i].compareTo(s[i + 1]) >= 0.0){
  String temp = s[i + 1];
  s[i + 1] = s[i];
  s[i] = temp;

  BubbleSortRecurse(s);
 	}
 }
	}
	
	static void BubbleSortRegular(String[] s){
 for (int i = 0; i < s.length; i++){
 	for (int j = 0; j < s.length - i - 1; j++){
  if (s[j].compareTo(s[j + 1]) >= 0.0){
  	String temp = s[j + 1];
  	s[j + 1] = s[j];
  	s[j] = temp;
  }
 	}
 }
	}
ASBands is offline   Reply With Quote
Old Jul 30th, 2004, 1:11 AM   #8
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
haha, bubble sort works... but the convergence on it is NASTY! O(N)^2 is not fun to deal with when working with really large datasets (and yes I have, lol).

Quicksort, that is the way to go A little tricky to implement (not as bad a merge sort) but the convergence on it is insane (do not remember it off the top of my head), probably something near O(n).
__________________
Clifford Matthew Roche &lt;geek@cliffordroche.com&gt;
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Jul 30th, 2004, 8:47 AM   #9
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Quick sort is probably top notch... but if I am not mistaken there is a faster sorting algorithm available, I do not recall its name. I wouldn't mind trying to make one of my own.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Jul 30th, 2004, 1:04 PM   #10
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
The only sort I know of that is faster then quick sort is heap Sort. The C++ STL uses a mix of heap sort (non stable) and quick-sort (stable) sorts.

There could be something faster I do not know about though, which is very possible.
__________________
Clifford Matthew Roche &lt;geek@cliffordroche.com&gt;
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:08 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC