Custom sort on data and not on cell value


During my implementation of custom sortings in my grid, I have came to a problem. My cells can contains numerical values like single values, range of values, or range of values plus mean. It is rendered in the cells as so:
Single Value:
10 cm (if unit is available)
Range of values:
10 to 20
10 to 20 cm (if unit is available)
Range of values plus mean:
10 to 20 - Mean: 15
10 to 20 - Mean 15 cm

when you register a custom_sort, you have 5 parameters:
function custom_sort(firstValue, secondValue, order, rowOfFirstValue, rowOfSecondValue).
The firstValue and SecondValue are the raw content of the cell (i.e. the text along with some HTML in my case).
Since my values are numerics, I would like to sort them by a numerical fashion (for example, by ascending/descending order of mean values).
I want to be able to have the rowId and the colId of the cells behind the firstValue and secondValue so that I can reach the real numerical values. Is that currently possible?

Thanks for your time.

You may get the rowId in the 4th and 5th parameter of the custom sorting function.
What about the column index you may try to get it from the onBeforeSorting event.
Something like:

var cur_sort_col;
myGrid.attachEvent("onBeforeSorting", function(ind,type,direction){
	return true;

Hello Sematik,
First, thanks for the information.
It looks like you are defining some global variable for all files. Is there really no way to get this column id in a clean way? like in the 6th parameter of the custom sorting function?

Also, your solution is working well as long as i have only one sort on the go, but it shouldn’t be robust against to clicks to sort two columns.
Anyway, I have tried your solution, but as i define my custom sorting function in my Grid class, it seems that when it is called by your framework, I am loosing the scope of my object, and i cannot retrieve the data it contains. Is there a way to bind a this to your function?

Thanks in advance.