• 
      

    Make image srcset and LocalDataQuerySet sorting future-proof.

    Review Request #9665 — Created Feb. 18, 2018 and submitted — Latest diff uploaded

    Information

    Djblets
    release-1.0.x
    7aa24dd...

    Reviewers

    Python 3 got rid of cmp() and related functionality, which broke two
    sorting-related bits of code: One for sorting image srcsets, and one for
    sorting entries in LocalDataQuerySet.

    The image srcsets was easily converted to using sort keys, which is
    preferred in Python 3 and is a bit faster than having a sorting
    function. LocalDataQuerySet needs a more advanced comparison function,
    so is now using functools.cmp_to_key(), which enables usage of our
    sorting function by implementing a key-like wrapper that calls into it
    for value calculation.

    Unit tests pass on Python 2.7. We're not in position to test on Python 3
    yet, though.