This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[Dolphn][Plasma5] Custom sorting order

1

Votes
2
1
Tags: None
(comma "," separated)
Lachu
Registered Member
Posts
864
Karma
1
OS
Modern desktop environments have build-in script engine (in most cases Java/Ecma Script language). My idea is to allow user to download sorting scripts form net or write own in JavaScript. This script would have read access for file names and metadata and will output array with files. Script wouldn't create file object. Users will download/write sorting script globally or directory-dependent (in this case it will be stored in directory's special file). You can extend the idea by adding way to place file on specify position, based on window size.

Use case:
Monica is C developer. She downloads source code of some program, extracts directory from tarball, open it and answer yes to question about sorting files by order defined in this directory as default. The order set README, COPYING, LICENSE, Makefile and configure as most important (first) files.


Lachu, proud to be a member of KDE forums since 2008-Nov.
airdrik
Registered Member
Posts
1854
Karma
5
OS
I like this idea, and especially like the example which puts the Readme, etc. files at the top.
Making it pluggable could then be used to accommodate some of the other suggestions I've seen requested, such as strict (case sensitive) name sort, sort by likes/rating or some other metadata.

I think rather than having the script return an array of items in the custom order, the script could just implement either a compare function which takes two files and returns higher/lower or a sortKey function which takes a single file and returns the criteria used for sorting. This would avoid problems due to a script returning a different number or set of results from what was passed in.


airdrik, proud to be a member of KDE forums since 2008-Dec.
Lachu
Registered Member
Posts
864
Karma
1
OS

Children ordering

Fri Jun 30, 2017 2:15 pm
What will be happen, when some two items get 0 from comparing function? I think, these two, three, etc. items could be compared by other compare function. The same rules will be apply to items examined as equal by second function, and so long.


Lachu, proud to be a member of KDE forums since 2008-Nov.
airdrik
Registered Member
Posts
1854
Karma
5
OS
In such cases then apparently it doesn't matter which order those two items are displayed and they are ordered arbitrarily (or using the order from before using this sort, which is usually used by whatever built-in sort function may be used).
Of course the script which returns a list of the items in the new order has to deal with that as well. The difference is then that one leaves it up to the engine to deal with it while the other leaves it up to the script writer to deal with it (most likely falling back on whatever the built-in sort function does).


airdrik, proud to be a member of KDE forums since 2008-Dec.
User avatar
arkascha
Registered Member
Posts
192
Karma
0
OS
I though about similar approaches a number of time.
What appears mighty and like a great idea always lost its glamour to me after a short time. In fact I failed to find realistic examples for an application. If there really is some single, often recurring and useful scenario, then this should be implemented as one of the basic sorting orders offered by the desktop environment. But I doubt there really are many.
About the specific example given:
Sure, keeping such files at the top sounds great to me too. But you are actually only trying to handle one single specific situation out of a countless number of arbitrary such scenarios. It would be _much_ easier to change the naming convention for such files to a pattern like `_README` or `_0_README`. With the current, arbitrary naming scheme you will always have exceptions. Do you want to implement a single sorting scheme for each project? Why? Why not simply rename the files and all is fine?
Lachu
Registered Member
Posts
864
Karma
1
OS
You're partially right, but think about possibility of downloading sorting order from network, so there's no need to changing names in each source directory - simple user open directory and select sorting order.

I also didn't write about possibility to group files by sorting algorithm. Dolphin allows to group files by sorting algorithm, so custom sorting algorithms should have possibility to group results too. Grouping items is something with wide angle of possibilities (and I think sorting have wide angle of possibilities too), for example by artist, genre of music, grouping files with and without warning/errors during analyzing, etc.


Lachu, proud to be a member of KDE forums since 2008-Nov.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]