Buy me a coffee! https://buymeacoffee.com/lucasbarake In this tutorial, we explore how to transform sorting in TypeScript by building a powerful Order module from scratch. Moving beyond basic array.sort() comparator functions, we'll create a system where sorting criteria becomes a first-class citizen in your codebase, making complex sorting logic both composable and type-safe. You'll learn how to compare primitives, compose multiple sorting criteria, and handle complex real-world sorting scenarios without writing nested comparison functions. The approach we'll explore is inspired by Effect's Order module, showing how functional programming patterns can elevate everyday programming tasks into elegant, maintainable solutions. Whether you're working with simple arrays or complex domain objects, these patterns will fundamentally change how you think about sorting data in TypeScript. Perfect for developers looking to deepen their understanding of functional programming and improve their code quality. 00:00 The Problem 02:45 Building the Order Module 06:23 Testing it Out 07:21 Generic Orders: mapInput 11:27 Composing Orders: combine 13:10 Reversing Orders: reverse 13:56 Inspiration