Python Forum
Sort by the largest number of the same results (frequency)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sort by the largest number of the same results (frequency)
#1
Hello

I have a sorting question
Now I’m using Notepad++ but it is difficult to sort in my way.

For example
I have few examples in random order

10AndrewJNVR
10Andrpt1Pf7
10Anuiot18g2
10Andrew1H54
10Andrew17yb
10Andre614uw
10Andr321EUb
10And48n1Q2K
10And1in15tA
10Andrew13gG
10An987ppKeP
10Andrew1Dom


How to sort text ie. in Notepad ++ (with python addon) like in bellow
at the very top after sorting there will be addressess with the names most often repeating or closest,
then subsequent, subsequent and subsequent ones as in the example below

So
How to sort to this way:



10Andrew1Dom
10Andrew1H54
10Andrew13gG
10Andrew17yb
10AndrewJNVR
10Andre614uw
10Andr321EUb
10Andrpt1Pf7
10And1in15tA
10And48n1Q2K
10Ana87ppKeP
10Anuiot18g2
Reply
#2
How do you know when to take all the letters and when not.
10Ana87ppKeP should come first ?

DPaul
Reply
#3
(Mar-25-2020, 04:49 PM)DPaul Wrote: How do you know when to take all the letters and when not.
10Ana87ppKeP should come first ?

DPaul

No, as You can see i need solution to find moast similar string so string with the most same characters
like
10Andrew1Dom
10Andrew1H54
10Andrew13gG
10Andrew17yb

then

10AndrewJNVR
10Andre614uw

and son on, so on
Reply
#4
Apart from the fact that i can think of better coding practices,
there is no simple way this can be done.

In my opinion, the reason is that you should sort on the
longest matching string (andrew1) to the smallest (an),
except you can't because they are hidden in the coded string.
If "an"... happens to be first you are going to have a lot of
matches, but you don't want the andrew1...to be included.
catch 22 if you ask me.

There is a possibility, but clumsy and elaborate. I have not worked it out.
What you could try:
for every entry in the list:
match the whole code with the other codes, write down the number of matches + length of the matchstring.
For that same code, take away the last position, do the same thing. [:-1]
Then take away the then last letter again, etc. until the len = 0
Then repeat the process for the second code, entc.
At the end you should be able to see what the longest len() with the most matches was.

Good luck
Paul
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  sort search results by similarity of characters jacksfrustration 5 405 Feb-16-2024, 11:59 PM
Last Post: deanhystad
Photo a.sort() == b.sort() all the time 3lnyn0 1 1,307 Apr-19-2022, 06:50 PM
Last Post: Gribouillis
Question Help to find the largest int number in a file directory SalzmannNicholas 1 1,612 Jan-13-2022, 05:22 PM
Last Post: ndc85430
  find 2 largest equal numbers Frankduc 13 3,525 Jan-11-2022, 07:10 PM
Last Post: Frankduc
  Largest product in a grid (projecteuler problem11) tragical 1 2,277 Sep-14-2020, 01:03 PM
Last Post: Gribouillis
  Search Results Web results Printing the number of days in a given month and year afefDXCTN 1 2,224 Aug-21-2020, 12:20 PM
Last Post: DeaD_EyE
  Extract the largest value from a group without replacement (beginner) preliator 1 2,071 Aug-12-2020, 01:56 PM
Last Post: DPaul
  frequency of largest number group anshumanmuj 5 2,979 Jun-22-2020, 04:51 PM
Last Post: perfringo
  How to append one function1 results to function2 results SriRajesh 5 3,120 Jan-02-2020, 12:11 PM
Last Post: Killertjuh
  Find the second largest number DarkCraftPlayz 8 11,263 May-29-2019, 02:46 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020