Need custom sorting algorithm - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +--- Thread: Need custom sorting algorithm (/showthread.php?tid=2154) Pages:
1
2
|
Need custom sorting algorithm - random1 - 11-12-2023 Hi all I m looking for a sorting algorithm, see image. Thanks in advance for your help. the sorting algorithm needs to sort the columns that are most similar like shown in the image above. The image was made by hand for illustration purposes. The attached file is just a small sample but the number of columns will always be 112. The idea is to find around 20 to 25 columns with the highest number of matching *'s The output only needs to show column numbers, Example, if 15 columns are found to have 6 *'s in common then those 15 columns will be the output, "5,12,22,35,43,50... n". The file I am processing often contains 500 or more lines each with 112 columns. This seems like it would be easy enough but once I started the more complicated it got. Any info would be greatly appreciated. R1 Sample file, this is a .txt file which on has 25 lines of data. https://app.box.com/s/38p52cfs6e6bbcbxsuhver7fxeb5dgcs RSample appreciate RE: Need custom sorting algorithm - SMcNeill - 11-12-2023 Would this little method basically be what you're looking for? Code: (Select All)
It counts the matches for each column and then shows the total at the bottom. All you'd have to do at this point is just search for the highest value and then display those that have that number of matches. RE: Need custom sorting algorithm - SMcNeill - 11-12-2023 Code: (Select All)
As so. (I decided to go in and finish the little routine here for you.) RE: Need custom sorting algorithm - Kernelpanic - 11-12-2023 In the Rnd function in the Wiki, the link to the "Marsaglia polar method" is incorrect. Correct: https://en.wikipedia.org/wiki/Marsaglia_polar_method RE: Need custom sorting algorithm - SMcNeill - 11-12-2023 (11-12-2023, 06:02 PM)Kernelpanic Wrote: In the Rnd function in the Wiki, the link to the "Marsaglia polar method" is incorrect. Correct: https://en.wikipedia.org/wiki/Marsaglia_polar_method You should post that in the wiki area, so a nice wiki editor will be certain to see it. RE: Need custom sorting algorithm - RhoSigma - 11-12-2023 (11-12-2023, 06:02 PM)Kernelpanic Wrote: In the Rnd function in the Wiki, the link to the "Marsaglia polar method" is incorrect. Correct: https://en.wikipedia.org/wiki/Marsaglia_polar_method fixed RE: Need custom sorting algorithm - Kernelpanic - 11-12-2023 (11-12-2023, 06:05 PM)SMcNeill Wrote:I looked there first, but there was nothing there. Ok, I just checked QB64 Wiki only.(11-12-2023, 06:02 PM)Kernelpanic Wrote: In the Rnd function in the Wiki, the link to the "Marsaglia polar method" is incorrect. Correct: https://en.wikipedia.org/wiki/Marsaglia_polar_methodYou should post that in the wiki area, so a nice wiki editor will be certain to see it. RE: Need custom sorting algorithm - random1 - 11-13-2023 (11-12-2023, 06:33 AM)SMcNeill Wrote: Would this little method basically be what you're looking for? RE: Need custom sorting algorithm - random1 - 11-13-2023 (11-12-2023, 06:43 AM)SMcNeill Wrote: RE: Need custom sorting algorithm - random1 - 11-14-2023 OK, I am basically back to my starting point. I have placed the top >= 60% columns into an array. Now I need to find 20 or so of these columns that show together most often. What I am left with is to format a string using 20 or so randomly selected values from the array then use brute force comparing string to string. Maybe my grandkids will still be here to see the results. My brain is laying down on the job, yesterday I could not remember which to use, roll, role, row. Getting old is a Bitch. Still accepting ideas from anyone with a working mind. R1 |