Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting numbers - FiliSort
#11
(03-10-2026, 10:17 PM)PhilOfPerth Wrote:
(03-10-2026, 09:21 AM)SMcNeill Wrote: @PhilOfPerth Variable length strings don't work with _MEM, so there's no easy way to use them with my MemSort routine.  It'll work for all other base variable types, but can't handle variable length strings.

The only thing to do is:

1) You could make all your strings a fixed length and then it'd sort them.  DIM array(10000) AS STRING * 20 <-- for example

2) Use a different sort routine to handle the variable length strings.  For my personal use, I tend to package and use a combSort routine for most things.  It's fast enough to handle anything I usually toss at it, it's non-recursive so there's no chance of blowing the stack, and it's simple enough for me to understand and alter if I ever need to change something with it.

If you want, I can share the routine I usually use for you.  I'm certain it's here on the forums, and probably attached to a dozen different programs and examples from the years, but I'm too lazy and it's too late at night right now to hunt for them.  If you want it, let me know, and I'll hunt it down once I get over this daylight swap jetlag which seems to be killing my energy levels. Wink
Thanks Steve, much appreciated.
I'll look for that CombSort, and give it a try, but may continue with my effort at converting the string to an integer as well. It would be nice to "invent" something - even a buckled wheel!  Big Grin

@PhilOfPerth If you are feeling out of sorts try here:
https://qb64phoenix.com/forum/showthread.php?tid=4523

OTOH if you are in the mood for invent'in here are a couple of findings about what comes first:
Code: (Select All)
If "Phil" < "phil" Then Print "Uppercase letters come first!" Else Print "Lower case letters are first!"
If "Phil" < "PhilOf" Then Print "Shorter word forms come first." Else Print "Longer word forms come first."
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#12
(03-10-2026, 10:46 PM)bplus Wrote:
(03-10-2026, 10:17 PM)PhilOfPerth Wrote:
(03-10-2026, 09:21 AM)SMcNeill Wrote: @PhilOfPerth Variable length strings don't work with _MEM, so there's no easy way to use them with my MemSort routine.  It'll work for all other base variable types, but can't handle variable length strings.

The only thing to do is:

1) You could make all your strings a fixed length and then it'd sort them.  DIM array(10000) AS STRING * 20 <-- for example

2) Use a different sort routine to handle the variable length strings.  For my personal use, I tend to package and use a combSort routine for most things.  It's fast enough to handle anything I usually toss at it, it's non-recursive so there's no chance of blowing the stack, and it's simple enough for me to understand and alter if I ever need to change something with it.

If you want, I can share the routine I usually use for you.  I'm certain it's here on the forums, and probably attached to a dozen different programs and examples from the years, but I'm too lazy and it's too late at night right now to hunt for them.  If you want it, let me know, and I'll hunt it down once I get over this daylight swap jetlag which seems to be killing my energy levels. Wink
Thanks Steve, much appreciated.
I'll look for that CombSort, and give it a try, but may continue with my effort at converting the string to an integer as well. It would be nice to "invent" something - even a buckled wheel!  Big Grin

@PhilOfPerth If you are feeling out of sorts try here:
https://qb64phoenix.com/forum/showthread.php?tid=4523

OTOH if you are in the mood for invent'in here are a couple of findings about what comes first:
Code: (Select All)
If "Phil" < "phil" Then Print "Uppercase letters come first!" Else Print "Lower case letters are first!"
If "Phil" < "PhilOf" Then Print "Shorter word forms come first." Else Print "Longer word forms come first."
Thanx bplus
That link is very useful; the code words well for my prog. My "buckled wheel" fell off after trying several ways to convert strings to integers. I'll still look at the CombSort that Steve mentioned, but this looks like the best solution.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using the tenary operator in C with 3 numbers Kernelpanic 16 4,258 09-13-2024, 06:06 AM
Last Post: Jack
  Test sorting algorithms eoredson 3 1,014 05-04-2023, 09:38 PM
Last Post: eoredson
  Serial Numbers AtomicSlaughter 1 807 03-13-2023, 05:45 PM
Last Post: mnrvovrfc

Forum Jump:


Users browsing this thread: 1 Guest(s)