Answered
Moving list item to index 0
Hello everyone, how do I move the selected item to "index 0" in the list?

var w = new Window ("dialog", "Rearrange");
var list = w.add ("listbox", undefined, ["one", "two", "three", "four", "five"]);
list.selection = 1;
var up = w.add ("button", undefined, "Index 0");
up.onClick = function () {
var n = list.selection.index;
if (n > 0) {
swap (list.items [n-1], list.items [n]);
list.selection = n-1;
}
}
function swap (x, y) {
var temp = x.text;
x.text = y.text;
y.text = temp;
}
w.show ();
