I threw the following quick sort code into place (I didn't want to use
a normal merge sort, in case very large lists are to be sorted... I
and populating new arrays and using big chunks of memory, especially
if complex objects are involved):
Sk.mergeSort = function(arr, cmp, key, reverse) // Replaced by
}Sk.quickSort = function(arr, cmp, key, reverse)
var partition = function(arr, begin, end, pivot)
// swap pivot, end-1
// swap end-1, store
var qsort = function(arr, begin, end)
pivot=partition(arr, begin, end, pivot);
qsort(arr, begin, pivot);
qsort(arr, 0, arr.length);
};On Jan 18, 10:43 am, Sphaerica <blacat...@comcast.net> wrote:
> Where did you get the in-place mergesort algorithm you used?
> Everything I've seen says such algorithms are complex and sometimes
> I may just replace yours with a regular mergesort, or a quicksort.
> On Jan 18, 1:33 am, Sphaerica <blacat...@comcast.net> wrote:
> > I think I see the sort problem. I'll fix it tomorrow.
> > On Jan 18, 12:18 am, Scott Graham <sgra...@gmail.com> wrote:
> > > A couple problems that need to be fixed:
> > > src/list.js doesn't have name parameters defined, so the cmp kwarg won't
> > > The second problem is that src/mergesort.js doesn't look like it sorts
> > > On Tue, Jan 17, 2012 at 5:28 PM, Sphaerica <blacat...@comcast.net> wrote:
> > > > mylist=[ (0,2), (3,1), (0,0), (4,5) ]
> > > > I had one problem which I fixed by modifying method.js to match
> > > > var numvarnames = varnames && varnames.length;
> > > > [I added "varnames &&" in case 'co_varnames' was undefined, as is the
> > > > Now mergesort is complaining that a (the first parameter, the array)
> > > > Where am I going wrong?
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.