Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need custom sorting algorithm
#15
I tried Rho's idea of just sorting the columns as strings (same as sorting binary numbers) but that IS too simple.

I suppose you could take each column and compare BOTH *'s and -"s to every other column
and tally up the matched chars and I suppose it is possible that some will have higher matches than others.

Come to think of it, when you compare two columns and count matches, you never have to compare those 2 columns again, nothing changes they both have same amount of matches.

So
for i= 1 to columns-1
for j = i +1 to columns
'compare
'tally matches for column i AND column j
next
next
then sort by matches

This would how I setup a random data set:
Code: (Select All)
Const columns = 65, rows = 21

Dim cr$(1 To columns, 1 To rows)
For r = 1 To rows
    For c = 1 To columns
        If Int(Rnd * 2) Then cr$(c, r) = "*" Else cr$(c, r) = "-"
        Print cr$(c, r);
    Next
    Print
Next
as opposed to how Steve set this up.

I'd be more motivated to finish code if @random1 or anyone can reveal to me a practical purpose to this.
It'd probably make it easier to code or find a better appraoches for the practical problem.
b = b + ...
Reply


Messages In This Thread
Need custom sorting algorithm - by random1 - 11-12-2023, 05:07 AM
RE: Need custom sorting algorithm - by SMcNeill - 11-12-2023, 06:33 AM
RE: Need custom sorting algorithm - by random1 - 11-13-2023, 11:04 AM
RE: Need custom sorting algorithm - by SMcNeill - 11-12-2023, 06:43 AM
RE: Need custom sorting algorithm - by random1 - 11-13-2023, 12:59 PM
RE: Need custom sorting algorithm - by SMcNeill - 11-12-2023, 06:05 PM
RE: Need custom sorting algorithm - by RhoSigma - 11-12-2023, 06:11 PM
RE: Need custom sorting algorithm - by random1 - 11-14-2023, 08:59 AM
RE: Need custom sorting algorithm - by bplus - 11-14-2023, 09:54 AM
RE: Need custom sorting algorithm - by SMcNeill - 11-14-2023, 10:35 AM
RE: Need custom sorting algorithm - by RhoSigma - 11-14-2023, 01:34 PM
RE: Need custom sorting algorithm - by SMcNeill - 11-14-2023, 04:35 PM
RE: Need custom sorting algorithm - by bplus - 11-14-2023, 06:07 PM
RE: Need custom sorting algorithm - by bplus - 11-15-2023, 02:51 AM



Users browsing this thread: 1 Guest(s)