stackyFACTS
JavaScript sorts numbers alphabetically by default
STACKY / Technology
Technology

JavaScript sorts numbers alphabetically by default

HERE’S THE INTERESTING PART

Without a comparator function, JavaScript converts values to strings, so [10, 2, 1] sorts as 1, 10, 2 rather than numerically.

One discovery leads to another.

Keep exploring facts in this topic.

Technology →
STACKY FOR IPHONE

A bigger world.
One discovery
at a time.

Keep discovering with Stacky. Interesting facts in an app that is always within reach.

Download on the App Store
ONE MORE DISCOVERY?

Keep exploring

All in this topic →
The sorting algorithm that just keeps shuffling
Technology

The sorting algorithm that just keeps shuffling

Bogosort checks whether a list is in order and, if it isn't, shuffles the whole list and tries again. It might finish on the first try—or keep going for an…

Discover more
Sorting algorithms aggressively bubble highest values up
Technology

Sorting algorithms aggressively bubble highest values up

It repeatedly compares neighboring numbers and swaps them when they're out of order, gradually moving the largest values to the top. The simple method is…

Discover more
Bogobogosort turns sorting into an exercise in wasted effort
Technology

Bogobogosort turns sorting into an exercise in wasted effort

The joke algorithm repeatedly sorts a smaller prefix, checks the next element, and reshuffles when the pieces fail to fit. Even checking progress can send it…

Discover more
The algorithm that sorts numbers by letting them sleep
Technology

The algorithm that sorts numbers by letting them sleep

Each number gets a thread that waits that many seconds before printing; smaller numbers wake first, so the list comes out sorted.

Discover more
Stalin sort gets an ordered list by deleting the dissenters
Technology

Stalin sort gets an ordered list by deleting the dissenters

The joke algorithm scans a sequence and discards values that break the chosen order. What survives is sorted, but information has disappeared. It exposes a…

Discover more
Technology

More people now discover news from algorithmic feeds than from traditional outlets, creating echo chambers tuned to outrage; the unseen shift isn’t just what stories people read,…

Imagine standing in a vast library where every book is available—but the shelves rearrange themselves to only show titles that confirm your mood, fears, or…

Discover more
StackyMore discoveries in the app
Download on the App Store