I have an array of objects which is obtained from JSON in PHP and all properties come back as a string (in quotes) the property required comes back as an int from the API.
I have a particular property let's say 'value' which I convert to integer type (using parseInt()) for each object in the array. I want to apply the orderBy $filter on this property but the order comes back in lexicographical order ( i.e. 9 then 88 then 8... etc) which as far as I'm aware means 'value' is being considered as a string.
The way I apply the filter is as follows:
scope.sortedItems = $filter('orderBy')(scope.sortedItems, sortItems, true);
which uses the function sortItems:
var sortItems = function(item) {
return [item[scope.orderProp], mapping[item.item_rarity]];
};
to apply secondary ordering as well as the primary.
I'm confused as I've also run isNaN on each property everytime the filter is applied and for each object, it comes back as false (is a number). There are some null values but I would assume this doesn't affect anything?
edit: modified the returned JSON to return integers but still no luck.