reorder_list | index /home/tom/py/reorder_list.py |
# ==================================================================
# Reorder the elements in a list
#
# Reorder the list every Nth element.
#
# Note: There is no way to recover the original order of the list
# elements when sort is used. The original list's order
# information is lost.
#
# See the sort related code. What happens when sort is used?
#
# ------------------------------------------------------------------
#
# For example with sort (step every third element):
#
# original list [44, 3, 56, 2, 56, 8, 9, 43, 22, 1]
# reordered list [1, 9, 44, 2, 22, 56, 3, 43, 56, 8]
# restored list? [1, 2, 3, 8, 9, 22, 43, 44, 56, 56]
#
# ==================================================================
#
# notes:
#
# 1. for python2 try xrange
#
# ==================================================================
Functions | ||
|