Ordering of Nodes and py3 compat

When ordering, unbound variables must come first, then blank nodes,
followed by IRIs and finally literals. (See [spec] [1])

This also fixes a Py3-incompatibility: [NoneType is not comparable] [2] in
Py3, but for an unbound variable `None` is used for sorting. As a side effect, this pull request fixes this problem.

[1]: http://www.w3.org/TR/2012/PR-sparql11-query-20121108/#modOrderBy
[2]: file:///usr/share/doc/python3.2-doc/html/whatsnew/3.0.html#ordering-comparisons