turns out not all systems have --version-sort in sort command! Rewrite version checking in pure BASH.