topk

command module
v0.0.0-...-87cc695 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2025 License: MIT Imports: 12 Imported by: 0

README

topk

A small utility for ad-hoc top-k analysis built in go.

Install

$ go install github.com/igorwwwwwwwwwwwwwwwwwwww/topk@latest

Usage

You can pass a filename:

$ topk types.txt
Water        112  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Normal        98  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Grass         70  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Bug           69  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Psychic       57  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Fire          52  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Rock          44  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Electric      44  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Ghost         32  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Dragon        32  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎

$ topk -other types.txt
Water        112  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Normal        98  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Grass         70  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Bug           69  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Psychic       57  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Fire          52  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎
Rock          44  ∎∎∎∎∎∎∎∎∎∎∎∎
Electric      44  ∎∎∎∎∎∎∎∎∎∎∎∎
Ghost         32  ∎∎∎∎∎∎∎∎
Dragon        32  ∎∎∎∎∎∎∎∎
OTHER        191  ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎

Alternatively, it's also possible to pipe from stdin:

$ cat types.txt | topk

For approximate results using the filtered space-saving algorithm, you can pass -approx:

$ topk -approx types.txt

Why

Because my fingers hurt from typing sort | uniq -c | sort -rn | head.

Similar to

License

MIT.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL