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.
Add test for zero dimensional netCDF variables
Ensure isrec always returns a boolean
Placate irritating pep8 checker
Merge pull request #3617 from takluyver/netcdf-sorting-fix

BUG: io: sort netcdf variables in a Python-3 compatible way