Hmmm, can you do a heap sort or merge sort with S2? ;)
I was going to suggest sorting tags by usage first, selecting the top 20, then re-sorting. However, it's probably not efficient to do so much sorting, and I see that quicksort function works only on string arrays.
you can do heap or merge if you can simplify it into s2 functions. :P
this is what i do:
run through TagDetails (Page::visible_tag_list()) to get highest use count while making a hash of TagDetails based on TagDetail.use_count
run through hash while copying TagDetail data, calculating font size, and creating an array of tag names (strings), then stop when max amount of list items has been reached
quicksort tag names (strings) so that we know which order to print them in
run through tag names (strings) and print tag links based on saved information (strings) in hash
what you seem to be proposing is:
sort linear array of TagDetails (Page::visible_tag_list()) by usage (TagDetail.use_count), but stop when max amount of list items is reached
yes, the cloud is in the sidebar thingy but you wanted to alter the TagsPage to have a cloud but only include the 20 most used tags. that takes some alteration of the code.
and i forgot to check one thing that would make or break this. you need a paid/permanent account to use custom layers. :\
i... don't quite understand what you're looking for.
a lot of the code contained in this entry is there because of how hash tables work. if i iterate over the hash, it won't be in alpha order. it'd be in the order as defined by the hash function.
do you want a
of tag links? do you want a comma- or space-separated list?
the idea that i'm getting of what you want would be much much simpler than the code here.
Comments 9
Reply
i came up with the rest with some ripping of the tagcloud fontsize code.
do you have a different idea that might be more efficient? if so, i'm willing to take a look at it.
feel free to take this code, refine it, and comment with your changes.
Reply
I was going to suggest sorting tags by usage first, selecting the top 20, then re-sorting. However, it's probably not efficient to do so much sorting, and I see that quicksort function works only on string arrays.
Reply
this is what i do:
Reply
Reply
it'd be easier for me to give more specific instructions if you made your layer(s) publically viewable and gave me the layerid numbers.
Reply
Also I dont know how to make my layers publically viewable :(
Reply
and i forgot to check one thing that would make or break this. you need a paid/permanent account to use custom layers. :\
Reply
(The comment has been removed)
a lot of the code contained in this entry is there because of how hash tables work. if i iterate over the hash, it won't be in alpha order. it'd be in the order as defined by the hash function.
do you want a
of tag links? do you want a comma- or space-separated list?
the idea that i'm getting of what you want would be much much simpler than the code here.
Reply
Leave a comment