code: def _cmp_by_aspath(path1, path2):
      
      as_path1 = path1.get_pattr(BGP_ATTR_TYPE_AS_PATH)
      as_path2 = path2.get_pattr(BGP_ATTR_TYPE_AS_PATH)
      assert as_path1 and as_path2
      l1 = as_path1.get_as_path_len()
      l2 = as_path2.get_as_path_len()
      assert l1 is not None and l2 is not None
      if l1 > l2:
          return path2
      elif l2 > l1:
          return path1
      else:
          return None
docs: Calculated the best-paths by comparing as-path lengths.
  
      Shortest as-path length is preferred. If both path have same lengths,
      we return None.