Re: Have we got a numeric sort yet?
- --- In firstname.lastname@example.org, "flo.gehrke" <flo.gehrke@...> wrote:
>Here is something I played with after digesting your code, Flo: an entertaining take on proper numeric sorting, without a lag of firing an external app though. It takes an array of numbers delimited with a (standard) semicolon. As is, it provides stock NT accuracy to the second decimal, but it can be set to one's liking with the variable %dec%. With its current algorithm it sorts and deduplicates smaller arrays (of about 200 elements) with a sub-second performance on my comp.
> However, it's an efficient work-around for me to use that DOS-tool EVAL.EXE I mentioned in 2009. You still can download it from
> My proposal was to use that tool with the following clips. Start with...
Somewhere in a parent clip:
And the function itself:
;Surround input with semicolons (to aid later replacements)
;Adjust only %dec% (desired decimal accuracy from 0 to whatever)
^!Set %dec%=2; %i%=2
;Append decimals where absent
^!If ^%i%<^%in0% Skip_-2
;Second element (the first is empty!) and index of third
^!Set %min%=^%in2%; %i%=3
;Get the smallest value iterating through pairs of elements
^!If ^%i%<^%in0% Skip_-2
;Drop located value in the new array-to-be
;Remove located value(s) from the input array
^!IfMatch ".*?;^%min%;.*" "^%in%" Skip_-1
;Start another walk-through if at least four elements remain
^!If ^%in0%>3 Find_Smallest
;Check for the possibility of only two empty elements remaining
^!IfEmpty ^%in2% Skip
;Get the last value
;Remove leading semicolon and set the results array
^!Set %in%=; %dec%=; %i%=; %min%=; %res%=
- --- In email@example.com, "Eb" <ebbtidalflats@...> wrote:
>... NoteTab is an interpreter, not a compiler. That means any complex algorithm you build in clip code is going to be much slower, than it would be as a compiled (built-in) function.I'm still impressed how quick clips run. Reminds me of writing good old Advanced Basic code running on an XT. You know, a 5.1 gogigahertz machine still processes a spreadsheet about as fast as it used to!
> Bubble sort requires (n squared) iterations in the worst-case scenario.That sounds better. Thanks for the reminder.
> On the other hand, it might be a good exercise to code in clip code. <grin>Just for comparison</grin>.Gone are the days of the lazy uni student where time was a misspent luxury... <sigh> ... although I can't complain.. I had an entire half a Sunday to sit and relax this week. :)
My current project needed a 'calculate by hand' style multiplication routine to handle ridiculously large numbers. To be honest, I don't mind the 7 seconds it takes to multiply two - one hundred digit -numbers.
Fascinating really and the exciting bit is that we seem to have come full circle and once again the computer is doing exactly what the user wants... without the OOP, "compiler declares headache" syndrome. <smile> </b>