Hello,
I could use some inspiration:
I wanna sort the currently open tabs according to specific criteria.
I am aware of the move() command as well as the sort(…) command for arrays.
I currently am thinking about going like this:
first get all tabs via the query({}) command.
then I wanna use the sort function with a custom comparator as such:
first sort by the “root url part”, namely if a tab has the url http://google.de/abcd
I want the ordering by dependent on the “google.de”
doesnt matter if http or https and doesnt matter whatever comes after the first singular /.
then if stuff is sorted that way, I then, where possible, want to order it further by the text displayed in the url bar, most likely the “title” attribute I would guess.
so namely, given 2 tabs a and b, I want one to be “higher” than the other if first of their root url part is lexicographically sorted (just alphabet wise sorting).
if they have the same base url., then they are sorted by title.
now after sorting everything (or at least have an array of the sorted tabs), I somehow need to move() all the tabs in a way so they in the end end up in the sorted positions.
I have a vague idea about this whole process but I am deeply struggling with certain parts.
for example how to move things.
cause if we wanna rearrange tabs in the order 4,1,3,2,5, how do you move what to achieve it?
cause if I place the 4th tab in the first position (yeah, index are 0 based in reality I know)
then the whole indizes of the other tabs changes and my “list of positions” has been rendered useless :-/
I jsut dont have the big mental click moment.
Can someone give me some good hints on how to do this plan?