Code Snippets

Category: Sorting & Data Structures

Sort a List of Dicts

Sort a list of dicts by a key with sorted() + itemgetter for speed.

Author: chris

Array map/filter/reduce

Compose map, filter, and reduce to transform a list of numbers.

Author: chris

Sort Slice of Structs in Go

Sort a slice of structs with sort.Slice and a less func.

Author: chris

Sort Vec by Key in Rust

Sort a Vec of structs by one field using sort_by_key.

Author: chris

Sort Array of Hashes by Key

Sort an array of hashes by a numeric attribute using sort_by.

Author: chris