I have the same question with the below poster about sortFn in ng-grid: Sort on underlying data in ng-grid the answer give the code in Plunker: http://plnkr.co/edit/qmBsneZ3HmFRKSkjbBWU?p=preview
var myData1 = [{name: "Moroni", age: {age: 50, ageWord: "Fifty"}},
{name: "Tiancum", age: {age: 43, ageWord: "Forty-Three"}},
{name: "Mildred", age: {age: 70, ageWord: "Seventy"}},
{name: "Jacob", age: {age: 27, ageWord: "Twenty-Seven"}}];
$scope.gridOptions = {
data: 'gridData',
columnDefs: [
{field: 'name', displayName: 'Name'},
{field:'age',
displayName:'Age',
cellTemplate: '<div class="ngCellText" ng-class="col.colIndex()"><span ng-cell-text>{{COL_FIELD.ageWord}}</span></div>',
sortFn: function (a, b) {
if (a.age < b.age) {
return -1;
}
else if (a.age > b.age) {
return 1;
}
else {
return 0;
}
}
}]
};
But, it did not change the list queue, in my opinion, the list would be 'Twenty-Seven,Forty-Three,Fifty,Seventy' correct? If not, how can i sort the ngGrid by sortFn keyword? All, thanks.