Results for “TOP”
Small, practical examples. Search by task or narrow things down below.
Include every row tied for the highest score
SQL: Compare with MAX rather than limiting to an arbitrary number of rows.
SQL✓ Tested
Include every row tied for the highest score
SQL Server: Compare with MAX rather than limiting to an arbitrary number of rows.
SQL Server✓ Tested
Include every row tied for the highest score
Postgres: Compare with MAX rather than limiting to an arbitrary number of rows.
Postgres✓ Tested
Include every row tied for the highest score
SQLite: Compare with MAX rather than limiting to an arbitrary number of rows.
SQLite✓ Tested
Select the largest values without sorting everything
Python: Use heapq.nlargest when only a small prefix of the ranking is required.
Python✓ Tested
Sort only the smallest requested prefix
C++: partial_sort orders the selected prefix without guaranteeing the order of the remainder.
C++✓ Tested
Blink without blocking the loop
Use elapsed millis time instead of delay for a repeating action.
millis✓ Tested
Check whether any item matches
JavaScript: some stops once a predicate succeeds.
JavaScript✓ Tested
Check whether any item matches
TypeScript: some stops once a predicate succeeds.
TypeScript✓ Tested
Check whether every item matches
JavaScript: every stops at the first failed predicate and returns true for an empty array.
JavaScript✓ Tested
Check whether every item matches
TypeScript: every stops at the first failed predicate and returns true for an empty array.
TypeScript✓ Tested
Compare binary buffers including zero bytes
C: memcmp checks an explicit byte length rather than stopping at a string terminator.
C✓ Tested