Fixed an IndexError during reordering.

Fixed #56