This should take the text that you have in the List View and sort it by the column of your choice (numerically or by text). I haven't tested it but it should work (I at least checked for syntax errors today
). I did have something else here but realised I needed to change the sort function for this to be possible. I hope you like it. If you want any more information about this (or find a bug) please don't be afraid to ask, you can find my email/WLM address in my profile.
code:
[...]
var PlusWnd;//The Plus/Child Window object that the List View is in
var ControlID;//the ControlId of the List View
var Col;//sort by this column number
[...]
//Get the text in the List View
var arr = new Array();
var i=0;
while(PlusWnd.LstView_GetItemText(ControlID,0,i)!=undefined){
arr[i] = new Array();
for(j=0;j<PlusWnd.LstView_GetCount(ControlID);j++){
arr[i][j] = PlusWnd.LstView_GetItemText(ControlID,j,i);
}
i++;
}
//Remove all the text in the List View
while(PlusWnd.LstView_GetCount(ControlID)!=0){
PlusWnd.ListView_RemoveItem(ControlID,0);
}
//Arrange the data in the correct order
for(i in arr){
if(i!=Col){
for(j in arr[i]){
arr[i][j] = arr[Col][j]+" "+arr[i][j];
}
arr[i] = arr[i].sort(num);
}
}
arr[Col][j] = arr[Col][j].sort(num);
for(i in arr){
if(i!=Col){
for(j in arr[i]){
arr[i][j] = arr[i][j].replace(RegExp("^"+arr[Col][j]+"\s",""),"");
}
}
}
//Put text back into the List View
for(j in arr[Col]){
PlusWnd.LstView_AddItem(ControlID,arr[Col][j],j,Col);
}
for(i in arr){
if(i!=Col){
for(j in arr[i]){
PlusWnd.LstView_SetItemText(ControllID,j,i,arr[i][j]);
}
}
}
[...]
//method of sorting array
function num(x,y){
x_value = parseInt(x);
y_value = parseInt(y);
if (x_value > y_value) return 1;
else if (x_value == y_value) return 0;
else return -1;
}