In any case , if anyone has an order preserving sort which applies to floats as well as ints & strings , let us know .
In any case , if anyone has an order preserving sort which applies toThis is trivial. As long as you can discriminate between objects
floats as well as ints & strings , let us know .
In any case , if anyone has an order preserving sort which applies to floats as well as ints & strings , let us know .
Insertion sort:
An elementary sorting algorithms with sorting time of order O(n^2).
Very simple algorithm. Extremely fast if the number of items to be sorted is small.
Gets too slow if the number of items to be sorted exceeds a certain limit.
Merge sort:
An advanced sorting algorithm with sorting time of order O(n*log(n)). Top-down approaches (recursive) as well as bottom-up approaches (iterative) of merge sort are possible and work equally well. More complicated than insertion sort.
Would be needlessly complicated if the number of data items is small.
On the other hand, this algorithm can handle much larger data sets within reasonable time.
I would suggest that you look at the algorithms and implement the sorting routines
yourself. This is easier than adapting someone else's code.
On Sunday, September 3, 2023 at 5:53:07 AM UTC-7, Heinrich Hohl wrote:Insertion Sort did prove to be quite slow for my processor simulator, but the slowness is at compile-time so it is just a minor nuisance.
Insertion sort:
An elementary sorting algorithms with sorting time of order O(n^2).
Very simple algorithm. Extremely fast if the number of items to be sorted is small.
Gets too slow if the number of items to be sorted exceeds a certain limit.
I have Insertion Sort for lists too. I used this in my <SWITCH construct primarily because it detects duplicate entries when the duplicate is first found so I can abort the compile with a helpful error message pointing at where the error occurred.
Merge sort:
An advanced sorting algorithm with sorting time of order O(n*log(n)).
Top-down approaches (recursive) as well as bottom-up approaches (iterative) >> of merge sort are possible and work equally well. More complicated than insertion sort.
Would be needlessly complicated if the number of data items is small.
On the other hand, this algorithm can handle much larger data sets within
reasonable time.
I would suggest that you look at the algorithms and implement the sorting routines
yourself. This is easier than adapting someone else's code.
Nobody has to adapt (rewrite) my code --- it is general-purpose so it can be put to use unmodified for whatever data you might have.
Reading books on algorithms and studying an "advanced" sort algorithm
such as Merge Sort is a waste of time --- this has been well known for decades.
There is a lot of work involved in writing the code that I have already written.
On Saturday, September 2, 2023 at 9:51:16 PM UTC+2, Bob Armstrong wrote:
In any case , if anyone has an order preserving sort which applies to floats as well as ints & strings , let us know .An order-preserving sorting algorithm is also called a "stable" sorting algorithm.
Merge sort:
An advanced sorting algorithm with sorting time of order O(n*log(n)). Top-down approaches (recursive) as well as bottom-up approaches (iterative) of merge sort are possible and work equally well. More complicated than insertion sort.
Would be needlessly complicated if the number of data items is small.
On the other hand, this algorithm can handle much larger data sets within reasonable time.
I would suggest that you look at the algorithms and implement the sorting routines
yourself. This is easier than adapting someone else's code.
A good reference is:Thanks . That does look rather clear if I have to resort to rolling my own .
Hans Werner Lang: “Sequential and parallel sorting algorithms” https://hwlang.de/algorithmen/sortieren/algoen.htm
Start with insertion sort and find out if the sorting time is still acceptable in the worstA great deal of the power of CoSy comes from recursive operations on its lists-of-lists .
case scenario (large data set). Otherwise look at Merge sort. The recursive method of
merge sort is slightly simpler to implement than the iterative one.
On Saturday, September 2, 2023 at 12:51:16 PM UTC-7, Bob Armstrong wrote:That's essentially what's done with Helmar's algorithm .
In any case , if anyone has an order preserving sort which applies to floatsI have a MergeSort in the novice package.
as well as ints & strings , let us know .
AFAIK, it is stable, although I never gave any thought to whether it was or not.
You pass the xt of a comparison function into the sort function.
I rely heavily on linked lists in my own programming.
I don't use arrays or trees unless there is some compelling reason to do so. Linked lists work well most of the time --- I got the idea of having a single data-structure that is generally used from Factor that has "sequences"
that it uses for pretty much all data.
It's been too long since I checked comp.lang.forth . comp.lang.apl has too little activity to bother with & I didn't realize that is far from true here .later column can disrupt the order of previously sorted columns .
Anybody got a good ` sort algorithm ?
I've been working on getting all my accounting " business ready " in CoSy . It's only been in the last few years approaching the facilities I had in my legacy K ( Kx.com ) CoSy .
See my SV-FIG presentation : https://www.cosy.com/CoSy/y23/SV-FIG_20230826_commentary.html .
I am surprised to find I never implemented a variant of the sort algorithm I use , https://cosy.com/4thCoSy/Code/CoSy/sort.f , for floats .
The fundamental algorithm , while impressively elegant has a more pervasive problem that it is not order preserving on identical elements . That means if sorting a table using the permutations associated with a sort , the equal elements in sorting of a
APLs & K only return the sorting permutation , aka ` grade , rather than the sorted list itself . I've yet to figure out how to get the permutation ( to apply to all columns in a table ) w/o doing the sort itself .
In any case , if anyone has an order preserving sort which applies to floats as well as ints & strings , let us know .
On Saturday, September 2, 2023 at 2:51:16 PM UTC-5, Bob Armstrong wrote:
It's been too long since I checked comp.lang.forth . comp.lang.apl hastoo little activity to bother with & I didn't realize that is far from
true here .
CoSy . It's only been in the last few years approaching the facilities I
Anybody got a good ` sort algorithm ?
I've been working on getting all my accounting " business ready " in
had in my legacy K ( Kx.com ) CoSy .
See my SV-FIG presentation : >https://www.cosy.com/CoSy/y23/SV-FIG_20230826_commentary.html .algorithm I use , https://cosy.com/4thCoSy/Code/CoSy/sort.f , for floats
I am surprised to find I never implemented a variant of the sort
.
The fundamental algorithm , while impressively elegant has a morepervasive problem that it is not order preserving on identical elements
. That means if sorting a table using the permutations associated with a
sort , the equal elements in sorting of a later column can disrupt the
order of previously sorted columns .
APLs & K only return the sorting permutation , aka ` grade , ratherthan the sorted list itself . I've yet to figure out how to get the >permutation ( to apply to all columns in a table ) w/o doing the sort
itself .
In any case , if anyone has an order preserving sort which applies to >floats as well as ints & strings , let us know .
Seems to me the only time sorting meant anything was to prepare data to
be saved to a GCR tape. Even a tape-to-tape merge/purge from ancient
times is essentially a source to destination sort only having to
actually sort the introduced data. So let's modernize ... Loading the
table elements, given a data standardization exists, into a b+tree index >solves the issues. 1) Never have to sort in the first place. 2) Add or >remove data any time. 3) Drill down ability. 4) On an Intel system
the space is trivial. 5) Order added is preserved on duplicates. 6)
Why are you sorting in the first place? 7) Is there a real need to
sort? Well, besides a human data presentation?
This comment comes on following an understanding of temperature
measurement and dealing with the associated instrumentation, say an 'S'
type thermocouple. The linearization process is to keep performing a
7th order polynomial against the acquisition data or calc it once and
have a lookup table based on said values. Well, CM would say "Calc it",
as memory was rather expensive and limited 'in the day', not so much
now, "as there is likely enough processor to do so". When you have 32
bit processors that can run on a 3V lithium coin cell for a decade+
while transmitting sub-GHz data every minute or so the entire while, the >battery will die of old age before you deplete it, energy usage is now >paramount. Maybe you need to factor your concept on needing to sort ...
Sorting seems from days past a way to benchmark a system ... And only thus.
Just put the data into the index in the first place. The index is the
table. Forward, backward, subsets, content, selective resolution,
duplicate check, expansion and contraction, you decide the data
selection. Sorting ... LOL
It's been too long since I checked comp.lang.forth . comp.lang.apl has too little activity to bother with & I didn't realize that is far from true here .I got plenty. They come in two flavors, address based and index based. The address based ones work with any structure, as long as they exist as pointer arrays. The comparison uses a call back function:
Anybody got a good ` sort algorithm ?
I have a MergeSort in the novice package.
My LIST data-structure is general-purpose --- it can contain
any kind of data.
You pass the xt of a comparison function into the sort function.
I rely heavily on linked lists in my own programming.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 475 |
Nodes: | 16 (2 / 14) |
Uptime: | 18:07:41 |
Calls: | 9,487 |
Calls today: | 6 |
Files: | 13,617 |
Messages: | 6,121,091 |