Results for “required”
Small, practical examples. Search by task or narrow things down below.
Select the largest values without sorting everything
Python: Use heapq.nlargest when only a small prefix of the ranking is required.
Python✓ Tested
Serialize an object
Turn a JavaScript object into JSON text.
JavaScript✓ Tested
Show the current directory
Print the absolute path of your current working directory before running commands that depend on relative paths.
directory✓ Tested
Show the first lines of a file
Read only the first three lines of a text file, useful for checking a header or previewing a large log.
head✓ Tested
Show the Linux distribution version
Read the distribution-provided operating system name and version from os-release.
os✓ Tested
Sort and deduplicate lines
Sort lines alphabetically and remove duplicate lines in a predictable C locale.
sort✓ Tested
Sort dictionaries by a value
Sort a list of dictionaries by a numeric field, leaving the original list unchanged.
sort✓ Tested
Sort numbers numerically
Supply a numeric comparator instead of JavaScript string sorting.
JavaScript✓ Tested
Split a string into words
Split text on whitespace, automatically treating repeated spaces, tabs, and line breaks as a single separator.
string✓ Tested
Split and trim text
Split simple comma-separated JavaScript text and trim each part.
JavaScript✓ Tested
Sum numeric values
Provide an initial accumulator for JavaScript reduce, including empty arrays.
JavaScript✓ Tested
Transform array values
Use map to create a JavaScript array of squared values.
JavaScript✓ Tested