I have a fairly simple third-party table structure that lists a field name in one column and a field value (always a number, sometimes a decimal number) in another. I’m using getCollection to retrieve all values that match a certain field name. I want to sort them from largest to smallest value, so right now, my getCollection call looks like this:
$c = $modx->newQuery('Stats');
$whereArray = array(
'statName' => 'tackles'
);
$c->where($whereArray);
$c->sortby('value','DESC');
$stats = $modx->getCollection('Stats',$c);
This works great on whole numbers. However, sometimes (but not always) the value field is a decimal, and sortBy is ignoring the decimal. The value field is varchar, which may be the problem, but I’m not sure how to store decimal and non-decimal numbers in the same field any other way (could use advice on that). What am I doing wrong? Thanks!