Fix sort crash

This fizes the original implementation where the compareTo function
caused crashes when the power usage list went above 32 items - credit Jia Arlan