Вот рабочая сетка сортировки, но у неё там 2 режима - навигации и перетаскивания:
<use id="iconGroup" xlink:href="#iconsDef" x="0" y="12"/>
<handler type="application/ecmascript" ev:event="scrollbar"><![CDATA[
if (dm.flow.folderNavLevel >= 1) {
var old = dm.view.tags.MainMenuReorderList.focusedIndex;
dm.view.tags.MainMenuReorderList.focusedIndex = prg;}
var prg = evt.progress;
var max = evt.maxvalue;
var min = 0;
if (!dm.flow.folderNavLevel) {
var old = dm.mainmenu.focusIndex;
dm.mainmenu.focusIndex = prg;}
var st=document.getElementById("NavLevel").getFloatTrait("y");
if (prg<5) {st=0;}
if ((prg>24 && st<5) || (prg<10 && st>=10)) {st=5;}
if ((prg>29 && st<10) || (prg<15 && st>=15)) {st=10;}
if ((prg>34 && st<15) || (prg<20 && st>=20)) {st=15;}
if ((prg>39 && st<20) || (prg<25 && st>=25)) {st=20;}
if ((prg>44 && st<25) || (prg<30 && st>=30)) {st=25;}
if ((prg>49 && st<30) || (prg<35 && st>=35)) {st=30;}
if ((prg>54 && st<35) || (prg<40 && st>=40)) {st=35;}
if ((prg>59 && st<40) || (prg<45 && st>=45)) {st=40;}
if (prg>59) {st=51;}
document.getElementById("NavLevel").setFloatTrait("y",st);
var icn = 0;
i = max+1;
if (i>24) {i=25;}
for (idx = 0; idx < i; idx++) {
document.getElementById("icon."+icn).setTrait("visibility", "visible");
document.getElementById("Lbl."+icn).setTrait("visibility", "visible");
document.getElementById("icon."+icn).setTrait("opacity", ".8");
document.getElementById("Lbl."+icn).setTrait("moto:scroll", "stop");
document.getElementById("Lbl."+icn).setTrait("fill-opacity", ".8");
document.getElementById("drag."+icn).setTrait("visibility", "hidden");
document.getElementById("grab."+icn).setTrait("visibility", "hidden");
var ps=(idx+st);
if (ps<0) {ps=(max-5+prg+idx);}
if (ps<0) {ps=0;}
if (ps>max) {
document.getElementById("icon."+icn).setTrait("visibility", "hidden");
document.getElementById("Lbl."+icn).setTrait("visibility", "hidden");
ps=0;}
if (ps==old) {oldI=icn;}
if (ps==prg) {
document.getElementById("icon."+icn).setTrait("opacity", "1");
document.getElementById("Lbl."+icn).setTrait("fill-opacity", "1");
document.getElementById("Lbl."+icn).setTrait("moto:scroll", "start");
dragFocus(prg,icn);
}
document.getElementById("icon."+icn).setTrait("xlink:href", "#SmallIcon." + ps);
document.getElementById("Lbl."+icn).textContent = ("")+document.getElementById("Label."+ps).textContent;
if (dm.view.isShiftingMode == 2 && ps==prg) {
document.getElementById("Lbl."+icn).textContent = ("")+document.getElementById("Label."+old).textContent;}
icn=icn+1;}
if (dm.view.isShiftingMode == 2) {
document.getElementById("Lbl."+oldI).textContent = ("")+document.getElementById("Label."+prg).textContent;}
for (idx = max+1; idx < 25; idx++) {
document.getElementById("drag."+idx).setTrait("visibility", "hidden");
document.getElementById("grab."+idx).setTrait("visibility", "hidden");
document.getElementById("Lbl."+idx).setTrait("visibility", "hidden");
}
if (st<5) {document.getElementById("UpIndicator").setTrait("visibility", "hidden");}
else {document.getElementById("UpIndicator").setTrait("visibility", "visible");}
if (st+24<max) {document.getElementById("DownIndicator").setTrait("visibility", "visible");}
else {document.getElementById("DownIndicator").setTrait("visibility", "hidden");}
var itemfps = document.getElementById("item."+prg);
var p = max+1;
var pm = (p-(parseInt(p/5))*5);
// UP
u=prg-5;
if (!pm) {
if (prg<5 && prg>0) {u=max+(-5+prg);}
}
else {
if ((pm==1 || pm==2) && prg==0) {u=max;}
if (pm==1 && (prg==1 || prg==2)) {u=max;}
if (pm==2 && prg==1) {u=max-1;}
if (pm==2 && prg==2) {u=max;}
}
if (u<0) {u=max;}
up = "#item." + u+"";
// DOWN
d=prg+5;
if (!pm) {
if (max-prg<5 && max-prg>0) {d=prg-max+5;}
}
else {
if ((pm==1 || pm==2) && max-prg==0) {d=0;}
if (pm==1 && (max-prg==1 || max-prg==2)) {d=max;}
if (pm==2 && max-prg==1) {d=1;}
if (pm==2 && max-prg==2) {d=max;}
}
if (d>max) {d=0;}
down = "#item." + d+"";
// LEFT
l=prg-1;
if (l<0) {l=max;}
left = "#item." + l+"";
// RIGHT
r=prg+1;
if (r>max) {r=0;}
right = "#item." + r+"";
itemfps.setAttributeNS("","nav-down", down);
itemfps.setAttributeNS("","nav-up", up);
itemfps.setAttributeNS("","nav-left", left);
itemfps.setAttributeNS("","nav-right", right);
]]>
</handler>
<script>
<![CDATA[
function dragFocus(fps,icn) {
if (dm.view.isShiftingMode == 2) {
document.getElementById("drag."+icn).setTrait("visibility", "visible");
document.getElementById("grab."+icn).setTrait("visibility", "hidden");}
else {
document.getElementById("grab."+icn).setTrait("visibility", "visible");
document.getElementById("drag."+icn).setTrait("visibility", "hidden");}
function reorderListener()
{
var listener = this;
this.update=function (index)
{dragFocus(fps,icn);}
}
dm.view.reorderListener = new reorderListener();
}
]]>
</script>
<handler type="application/ecmascript" ev:event="unload">
<![CDATA[
dm.view.reorderListener = null;
]]>
</handler>