def comparePortionDirection(portionDirection, otherPortionDirection):
 if (portionDirection.portion > otherPortionDirection.portion):
  return 1
 if (portionDirection.portion < otherPortionDirection.portion):
  return (-1)
 if (portionDirection.directionReversed < otherPortionDirection.directionReversed):
  return (-1)
 return (portionDirection.directionReversed > otherPortionDirection.directionReversed)

def comparePortionDirection ( portionDirection , otherPortionDirection ) : if ( portionDirection . portion > otherPortionDirection . portion ) : return 1 if ( portionDirection . portion < otherPortionDirection . portion ) : return ( - 1 ) if ( portionDirection . directionReversed < otherPortionDirection . directionReversed ) : return ( - 1 ) return ( portionDirection . directionReversed > otherPortionDirection . directionReversed )
comparison in order to sort portion directions in ascending order of portion then direction .