Sort netcdf variables in a Python-3 compatible way

The previous implementation ran into issues with comparing different types (tuples and bools).

Also simplified the sorting, since Python 2.3 support is no longer an issue.