Implement Sort, and Fix template layout