Custom ORDER BY Explanation

@Scott Bailey suggested great idea. But it can be even simpler (you don’t have to create custom function) since PostgreSQL 9.5. Just use array_position function: ORDER BY array_position(array[‘Nails’,’Bolts’,’Washers’,’Screws’,’Staples’,’Nuts’], s.type)

Custom Order in Oracle SQL

Don’t know if this qualifies as simple: order by case when currency = ‘USD’ then 1 when currency = ‘BHT’ then 2 when currency = ‘JPY’ then 3 when currency = ‘MYR’ then 4 else 5 end or a bit more compact but Oracle specific: order by decode(currency, ‘USD’, 1, ‘BHT’, 2, ‘JPY’, 3, ‘MYR’, … Read more

C# list.Orderby descending

Sure: var newList = list.OrderByDescending(x => x.Product.Name).ToList(); Doc: OrderByDescending(IEnumerable, Func). In response to your comment: var newList = list.OrderByDescending(x => x.Product.Name) .ThenBy(x => x.Product.Price) .ToList();