![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2004
Posts: 1
Rep Power: 0
![]() |
A generic Sorter
|
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
And what a great tutorial that was
![]() |
|
|
|
|
|
#3 |
|
Expert Programmer
|
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 |
|
|
|
|
|
#4 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
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 |
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() |
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! |
|
|
|
|
|
#6 |
|
Programming Guru
![]() ![]() ![]() |
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." |
|
|
|
|
|
#7 |
|
Newbie
Join Date: Jul 2004
Posts: 1
Rep Power: 0
![]() |
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;
}
}
}
} |
|
|
|
|
|
#8 |
|
Expert Programmer
|
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 <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#9 |
|
Programming Guru
![]() ![]() ![]() |
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." |
|
|
|
|
|
#10 |
|
Expert Programmer
|
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 <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|