Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting numbers - FiliSort
#7
(03-08-2026, 06:55 PM)SMcNeill Wrote:
(03-08-2026, 05:55 PM)bplus Wrote: here is 20,000 random numbers between -50 and 50 that took no time to sort!!!

..snip

Well yeah... Of course that took no time to sort, as it *did no sorting*.  Tongue

You created an array large enough to hold all the possible values of the numbers generated, then simply counted the numbers and placed it into that array at creation time.  There's no sorting going on here and this uses 40MB of memory to hold 20,0000 bytes of data.  

If that's what you consider an improvement, I'd hate to see what somebody considers something worse!!  LOL!!



(-5,000,000 TO +5,000,000)  <this is an array of 10,000,000 elements.
Each element is 4 bytes in size as it's simply Dim Shared n(-5000000 To 5000000)  and you did a DEFLNG A-Z earlier, making everything LONG types.

So 10,000,000 elements * 4 bytes = 40,000,000 bytes to hold the data.

The data is only 20,000 numbers which are from -50 to 50, which can be stored in single bytes.   So... 20,000 bytes of data.

That's ONLY 2000 times overhead involved in this process.

WHATTA KEEPER!!  Big Grin Big Grin Wink

It's a good thing this didn't use DOUBLE precision to start with, or else we'd really see some impressive amounts of memory in work then with an array large enough to hold every value!



A second thought which I had with this process is I'm willing to bet YOU CORRUPTED YOUR DATA.

x = 1.23456
x * 100000 = 123456.654376474256356685 due to the imperfections of floating point math.  This would round up in the counter to 123457 and your data would be corrupted.

I don't see how this is a reliable improvement in any form, once you start looking at how it actually works and performs without taking speed into consideration.

Some people cant take a joke Tongue
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
Sorting numbers - FiliSort - by 2112 - 03-08-2026, 04:34 PM
RE: Sorting numbers - FiliSort - by bplus - 03-08-2026, 05:38 PM
RE: Sorting numbers - FiliSort - by bplus - 03-08-2026, 05:55 PM
RE: Sorting numbers - FiliSort - by SMcNeill - 03-08-2026, 06:55 PM
RE: Sorting numbers - FiliSort - by bplus - 03-08-2026, 07:27 PM
RE: Sorting numbers - FiliSort - by 2112 - 03-08-2026, 06:51 PM
RE: Sorting numbers - FiliSort - by SMcNeill - 03-08-2026, 07:06 PM
RE: Sorting numbers - FiliSort - by PhilOfPerth - 03-10-2026, 08:19 AM
RE: Sorting numbers - FiliSort - by SMcNeill - 03-10-2026, 09:21 AM
RE: Sorting numbers - FiliSort - by PhilOfPerth - 03-10-2026, 10:17 PM
RE: Sorting numbers - FiliSort - by bplus - 03-10-2026, 10:46 PM
RE: Sorting numbers - FiliSort - by PhilOfPerth - 03-11-2026, 12:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using the tenary operator in C with 3 numbers Kernelpanic 16 4,259 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)