Made version sorting more robust