Algorithms for Ordering