PREP WITH PROOF
Menu
FREE DATA LEARNING TOOL · NO SIGNUP

Top-K cutoff explorer

See who makes the cut when scores tie. Compare exact K by input order, exact K by ID, and all records tied at the cutoff.

Compare top-K policies

One ID,score per line, with no header. Up to 60 records and 4,096 characters. Use unique, case-sensitive ASCII IDs of 1–32 letters, digits, underscores or hyphens. Scores allow an optional minus, up to nine integer digits and three decimal places. Blank lines are ignored. Use K from 0 to 60.

The comparison runs in this page. The tool does not save your input or send it to a calculation service. Inputs and results are masked from optional session recording. Use non-sensitive examples.

Selection results

6 records · K = 3 · Cutoff score 92 · 3 at that score.

Exact K, input order for ties
3 selected: birch → fir → cedar
Exact K, ascending ASCII ID for ties
3 selected: birch → fir → alder
Include all ties at the cutoff
5 selected: birch → fir → cedar → ash → alder (+2 beyond exact K)
Each cell shows the returned position, or a dash if the record was excluded.
IDScoreInput positionExact K: inputExact K: IDAll cutoff ties
cedar92 · cutoff13—3
birch952111
ash92 · cutoff3——4
elm854———
fir955222
alder92 · cutoff6—35

Select and copy the report to keep the normalized scores, input positions, and each returned order.

What changes when three scores tie at the cutoff?

In the default example, birch and fir score 95. Cedar, ash and alder score 92. For K = 3, input order gives the last slot to cedar. Ascending ASCII ID gives it to alder. Keeping everyone at the cutoff returns five records, with equal scores in input order. The comparison table shows exactly which rows move or drop out.

Choose the tie policy before comparing results

Use input order when it represents a meaningful arrival sequence. Use stable IDs when the same records should win after the input is reshuffled. Use an inclusive cutoff when excluding any equally scored record would violate the reporting rule. That policy can exceed K by more than one, so check the output budget.

Read the result when K does not name a row

At K = 0 all policies return nothing. If K exceeds the number of records, all available records are returned, in each policy’s declared order, and there is no Kth score. An empty input produces no winners. When K equals the input length, the last score is the cutoff and no additional rows can be included.

How scores and IDs are compared

Scores are stored as integer thousandths, so spellings such as 1.2 and 1.200 compare equally. Negative zero displays as zero. The ID policy uses case-sensitive ASCII order, which places uppercase A before lowercase a. This is an exact comparison for the accepted format, not a locale-aware sort or a floating-point tolerance.

Take the same policy into your code

This small tool sorts its bounded input to show all comparison rows. It does not benchmark heap selection or process a live stream. The Python top-K guide includes tested selection examples and a bounded heap. For full-array order and mutation, use the sorting explorer.

References: Python heapq selection and stable sorting and secondary keys.