Special Rule for Directory Sort Order


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]