Fix bug, add else part, $max_int, and change sort() to ksort() -refs BT#8185
Merge pull request #50 from danbarretodev/8185

Fix bug -refs BT#8185