[#24] Correctly sort even when the data has NaN values inbetween the records

The problem was that we were returning 0 if any of the compared values were
NaN, which meant that if one value was NaN but the other wasn't, they would be
considered "equal" sorting-wise. In the end, it messed up with the sorting
order.

With this patch, the NaN records will be grouped in one of the sides of the
sorted array, not mixed inbetween, so when we create the chart, the elements
will be in the correct order.