H
HERC777
Right, got it going! I thought all sort algorithms had square
complexity worst case, and the recursive ones (quicksort, mergesort..)
had log linear average case.
That only works for a discrete range of values, but I adapted it using
a 2D array to store pointers to the file I'm sorting, sorting on line
length.
for (i=0;i<line;i++) {
ll = lines.length
linarr[ll] [full[ll]] = i
full[ll]++
}
Same as yours but it stores an array of pointers for each size so it
keeps track of the elements it sorted, instead of just counting them.
Then I just grab the elements back out in order.
sfile = ""
for (i=0;i<linesize;i++) {
for (j=0;j<full;j++) {
sfile += lines[linarr[j]]
}
}
Single pass sorting, 1,000s of times faster than my 1st attempt with
bubblesort.
Herc
complexity worst case, and the recursive ones (quicksort, mergesort..)
had log linear average case.
That only works for a discrete range of values, but I adapted it using
a 2D array to store pointers to the file I'm sorting, sorting on line
length.
for (i=0;i<line;i++) {
ll = lines.length
linarr[ll] [full[ll]] = i
full[ll]++
}
Same as yours but it stores an array of pointers for each size so it
keeps track of the elements it sorted, instead of just counting them.
Then I just grab the elements back out in order.
sfile = ""
for (i=0;i<linesize;i++) {
for (j=0;j<full;j++) {
sfile += lines[linarr[j]]
}
}
Single pass sorting, 1,000s of times faster than my 1st attempt with
bubblesort.
Herc