Add generic reordering method, fixes #23