Special Rule for Directory Sort Order

Is it possible to have a rule that "breaks" the defined sort order settings? I'll give you the example of I'm wanting to do.

Generally, I always prefer sorting directories above files. However, sometimes I have a huge list of directories, and there is one application that controls the content in that directory. I'd like to be able to use a special character to have the shortcut to that application sort to the top of the listing.

Example:

The directory "Music" contains hundreds of folders.
Whenever I'm actually listening to local music instead of streaming, I use Resonic player. I'd like the shortcut to Resonic to show up at the top of the list instead of at the very bottom of these hundreds of folders.

So, could I define a special character that always sorts to the top regardless of file/folder type?

Maybe "%" for example. "%Resonic.lnk"

:thumbsup:


Install the script column (below) similar to the one shown in Column - Roman Numerals for sorting names.

Turn on Display / Mixing: Mix files and folders together in the folder's folder format.

Then add the Script > Special column and sort by it.

Script download:

Special Sort Column.js.txt (1.06 KB)

Script contents:

[code]// Special Sort Column

function OnInit(initData)
{
initData.name = "Special Sort Column";
initData.desc = "A column to sort a specific file to the top of the list.";
initData.version = "1.0";
initData.default_enable = true;

var col = initData.AddColumn();
col.name = "SpecialSort";
col.method = "OnSpecialSort";
col.label = "Special";
col.justify = "left";
col.autogroup = true;
col.namerefresh = true;
col.autorefresh = false;
}

function OnSpecialSort(scriptColData)
{
if (scriptColData.col != "SpecialSort")
return;

if (scriptColData.item.is_dir)
{
scriptColData.value = "Dir";
scriptColData.sort = 1;
}
else
{
var nameUpper = scriptColData.item.name.toUpperCase();
if (nameUpper == "RESONIC.LNK" || nameUpper == "FOOBAR2000.LNK")
{
scriptColData.value = scriptColData.item.name_stem;
scriptColData.sort = 0;
}
else
{
scriptColData.value = "File";
scriptColData.sort = 2;
}
}
}[/code]

This is absolutely perfect! Thanks so much Leo. Cheers.