code: def _cmpkey(epoch, release, pre, post, dev, local):
      # When we compare a release version, we want to compare it with all of the
      # trailing zeros removed. So we'll use a reverse the list, drop all the now
      # leading zeros until we come to something non zero, then take the rest
      # re-reverse it back into the correct order and make it a tuple and use
      # that for our sorting key.
      release = tuple(
          reversed(
              list(
                  itertools.dropwhile(
                      lambda x: x == 0,
                      reversed(release),
                  )
              )
          )
      )
  
      # We need to "trick" the sorting algorithm to put 1.0.dev0 before 1.0a0.
      # We'll do this by abusing the pre segment, but we _only_ want to do this
      # if there is not a pre or a post segment. If we have one of those then
      # the normal sorting rules will handle this case correctly.
      if pre is None and post is None and dev is not None:
          pre = -Infinity
      # Versions without a pre-release (except as noted above) should sort after
      # those with one.
      elif pre is None:
          pre = Infinity
  
      # Versions without a post segment should sort before those with one.
      if post is None:
          post = -Infinity
  
      # Versions without a development segment should sort after those with one.
      if dev is None:
          dev = Infinity
  
      if local is None:
          # Versions without a local segment should sort before those with one.
          local = -Infinity
      else:
          # Versions with a local segment need that segment parsed to implement
          # the sorting rules in PEP440.
          # - Alpha numeric segments sort before numeric segments
          # - Alpha numeric segments sort lexicographically
          # - Numeric segments sort numerically
          # - Shorter versions sort before longer versions when the prefixes
          #   match exactly
          local = tuple(
              (i, "") if isinstance(i, int) else (-Infinity, i)
              for i in local
          )
  
      return epoch, release, pre, post, dev, local
  
imports: from __future__ import absolute_import, division, print_function
  import collections
  import itertools
  import re
  from ._structures import Infinity
label_desc: Use image node_id 6 for calling a global function with example usage: _cmpkey(epoch, release, pre, post, dev, local) and returns: epoch,  release,  pre,  post,  dev,  local