All Projects → lukechampine → intersort

lukechampine / intersort

Licence: MIT license
Sort anything.

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to intersort

Angular-Table-Sort-Component
Sorting Algorithm for sorting table values in angular
Stars: ✭ 18 (-67.27%)
Mutual labels:  sort
Sorting-Algorithms
sorting algorithms in python
Stars: ✭ 15 (-72.73%)
Mutual labels:  sort
laravel-auto
Laravel Auto - a helper package to make automated lists with filters, sorting and paging like no other
Stars: ✭ 41 (-25.45%)
Mutual labels:  sort
sortboard
A small ES6 library for easy sorting and filtering of elements.
Stars: ✭ 29 (-47.27%)
Mutual labels:  sort
vscode-yaml-sort
This VS Code extension exposes the possibility to sort, format and validate yaml files.
Stars: ✭ 25 (-54.55%)
Mutual labels:  sort
express-mquery
Expose mongoose query API through HTTP request.
Stars: ✭ 37 (-32.73%)
Mutual labels:  sort
algorithms
The All ▲lgorithms documentation website.
Stars: ✭ 114 (+107.27%)
Mutual labels:  sort
sortr-cli
a cli tool to sort files in your machine 🗃
Stars: ✭ 12 (-78.18%)
Mutual labels:  sort
ultra-sort
DSL for SIMD Sorting on AVX2 & AVX512
Stars: ✭ 29 (-47.27%)
Mutual labels:  sort
array-sort-by
Powerful mechanism to sort arrays or array of objects by one or more properties. You can also specify a custom comparer function.
Stars: ✭ 37 (-32.73%)
Mutual labels:  sort
spring-boot-jpa-rest-demo-filter-paging-sorting
Spring Boot Data JPA with Filter, Pagination and Sorting
Stars: ✭ 70 (+27.27%)
Mutual labels:  sort
ShiftSort
Sorting algorithm quicker than MergeSort, and is adaptive and stable.
Stars: ✭ 39 (-29.09%)
Mutual labels:  sort
Tracking-with-darkflow
Real-time people Multitracker using YOLO v2 and deep_sort with tensorflow
Stars: ✭ 522 (+849.09%)
Mutual labels:  sort
algos
A collection of algorithms in rust
Stars: ✭ 16 (-70.91%)
Mutual labels:  sort
myleetcode
♨️ Detailed Java & Python solution of LeetCode.
Stars: ✭ 34 (-38.18%)
Mutual labels:  sort
gson
Algorithms on data formats - JSON, CBOR, Collation.
Stars: ✭ 17 (-69.09%)
Mutual labels:  sort
Algorithms
Short explanations and implementations of different algorithms in multiple languages
Stars: ✭ 37 (-32.73%)
Mutual labels:  sort
postcss-sort-media-queries
PostCSS plugin for combine and sort CSS media queries with mobile first or desktop first methods.
Stars: ✭ 118 (+114.55%)
Mutual labels:  sort
quickselect
A fast selection algorithm in JavaScript.
Stars: ✭ 73 (+32.73%)
Mutual labels:  sort
AppListManager
📱 AppListManager (Android Library) makes managing application and activity lists easy.
Stars: ✭ 59 (+7.27%)
Mutual labels:  sort

intersort

intersort sorts slices of arbitrary objects according to the rules of Go's fmtsort package. fmtsort is an internal package and thus cannot be imported directly; however, its behavior is exposed via the fmt package when printing maps. So we can sort arbitrary objects by sticking them in a map, printing it, and parsing the result.

In other words, this package is an abomination and should not be used for anything. May the Go maintainers have mercy on my soul.

NOTE: This package requires Go 1.12.1.

Examples:

ints := []int{3, 1, 2}
intersort.Sort(ints) // [1, 2, 3]

strs := []string{"b", "c", "a"}
intersort.Sort(strs) // [a, b, c]

type Point struct {
    X, Y int
}
points := []Point{{2, 1}, {1, 1}, {1, 0}}
intersort.Sort(points) // [{1, 0}, {1, 1}, {2, 1}]

You can even sort differing types!

objs := []interface{}{3, true, 1, "wat", http.DefaultClient, false}
sort.Sort(intersort.Slice(objs)) // [false, true, 1, 3, wat, &{<nil> <nil> <nil> 0s}]

However, the results of this may vary, and in general are unpredictable; see golang/go#30398.

Advance praise for intersort:

I tend to think that exposing the comparison function would be an attractive nuisance. - Ian Lance Taylor

It was a deliberate decision to keep this implementation private. - Rob Pike

Sorting [arbitrary objects] is not even possible in the general case. - cznic

This should not be done. - Rob Pike

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].