Page 1 of 1

Sort By Most Popular Tags

Posted: 25 Apr 2020 06:23
by muzicman82
In my next adventure, I am looking for how I can set up a view that sorts by the most popular tags? The top of the list would have all files with the tag that appears on the most files, and the last files in the list would have tags that may be attached to only one file. I suppose trouble comes with a file has multiple tags. I would just say that the most popular tag takes over the sort.

Re: Sort By Most Popular Tags

Posted: 25 Apr 2020 07:13
by highend
Get all tags from all files in the current folder
Build a lookup table that stores the number of occurrences for each single tag + the tag itself (one combination for each tag)
Loop over all files, build a final list that contains the file, the highest count from the lookup table for its tags (choose the largest number of all tags it has, here)
Loop over the final list, populate extra columns with the result (highest count + belonging tag) and sort by it

Re: Sort By Most Popular Tags

Posted: 25 Apr 2020 08:40
by highend
Looks doable...
A few foreach loops would be necessary but it shouldn't require more than ~40 lines

Extra 1 = The count so that the list can be sorted
Extra 2 = The tag that was found most often and led to that count value
2020-04-25_083558.png