Original date:2014-11-05 20:59:33 Edited by: petelomax Subject: Re: Euphoria's identity/philosophy Where is the focus?

[quote jimcbrown] [quote Spock] The solution has always been around: Merge Sort - but not the one that was in the old Eu demos. Rob made a mistake in the code and the sort was not stable unless you change the comparison:

if compare(a[1], b[1]) < 0 then -- wrong, not stable  
if compare(a[1], b[1]) <= 0 then -- good, stable since the first element is placed sooner in the sequence when compared to an equal second element 


Sounds good to me. I don't see any hurdle to getting this change into trunk.

[/quote] Don't let me stop you, but I have to point out that such a change is almost completely pointless. If I sort {2,1,2,3} and get {1,2,2,3} or {1,2,2,3}, it matters not one jot. Ever.

ERM..., unless those 2's are the subject of different delete_routine()s, but that is a bit baroque, to say the least, and if I hadn't mentioned it you probably wouldn't have thought of it, right?

Given that delete_routine() did not exist at the time it was written, the statement "Rob made a mistake in the code and the sort was not stable" is utterly wrong, on all counts.

Hee hee. Look Ma, I too can troll. But in this case at least, I am right.

Of course if you had a custom_merge_sort() based on the revised merge_sort() of the old Eu demo, then it would indeed make a more obvious and significant difference, and on that basis (alone) it is a good change to make.


Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu