Sorting Strings
|
07-14-2017, 08:11 AM
(This post was last modified: 07-14-2017 08:24 AM by Didier Lachieze.)
Post: #13
|
|||
|
|||
RE: Sorting Strings
Well my first version was more a proof of concept and was not optimized.
As you mention, calling Chunk() in the comparison function is suboptimal as each string will be split multiple times, each time the sort algorithm will compare it to another string. So we need to move the "chunkification" out of the sort function, to do it just once. This can be done by replacing each string by a list composed of the string followed by the chunks, and applying the sort function to this list of lists which requires just minimal changes to Comp(). Then extracting the first element of each sublist will return the original strings sorted. Here is the second and faster version of Alphanum implementing this change : Code: // Alphanum: sort a list of strings_containing Another thing hitting the performance is that Comp() is written as a HOME program. So there is a penalty for the conversion from CAS to HOME to CAS environment every time sort() is calling Comp(). The solution is to rewrite Comp as a CAS function. But right now I have some troubles with the CAS "while" statement. I've converted all other instructions from HOME to CAS functions but "while" is not working, I'm getting an error message: "Error: Bad argument count" Code: // Compare two custom lists l1, l2 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Sorting Strings - Jacob Wall - 07-10-2017, 12:18 AM
RE: Sorting Strings - webmasterpdx - 07-10-2017, 04:58 AM
RE: Sorting Strings - Joe Horn - 07-10-2017, 07:22 AM
RE: Sorting Strings - Jacob Wall - 07-10-2017, 05:02 PM
RE: Sorting Strings - Tyann - 07-11-2017, 05:03 AM
RE: Sorting Strings - Tyann - 07-11-2017, 06:06 PM
RE: Sorting Strings - Jacob Wall - 07-11-2017, 06:21 PM
RE: Sorting Strings - Didier Lachieze - 07-11-2017, 11:32 PM
RE: Sorting Strings - Gilles59 - 07-12-2017, 08:28 PM
RE: Sorting Strings - Han - 07-12-2017, 12:32 AM
RE: Sorting Strings - Jacob Wall - 07-12-2017, 05:10 AM
RE: Sorting Strings - Jacob Wall - 07-14-2017, 07:02 AM
RE: Sorting Strings - Didier Lachieze - 07-14-2017 08:11 AM
RE: Sorting Strings - Jacob Wall - 07-15-2017, 03:00 AM
|
User(s) browsing this thread: 11 Guest(s)