Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have a grid that is 4 columns wide, 4 rows high, I can get the "total" number of a certain point like this:

(y * width) + x

So point (0,1) would be calculated like this (1 * 4) + 0 = 4

But does that have some kind of fancy name, something I could use in my code?

share|cite|improve this question
up vote 1 down vote accepted

Sorting points in your grid according to the values of the function $(x, y)\mapsto y\cdot\mathrm{width} + x$ is commonly called lexicographic order or dictionary order, since it yields the same order you would get if you sorted the ordered pairs (0, 0), (0, 1), ..., (3, 2), (3, 3) as though they were words in a dictionary. A function which maps one set into a total order is often called a sort key (in programming) or a linear extension (especially in order theory).

share|cite|improve this answer
Exactly what I was looking for, thanks! – skerit Nov 26 '11 at 10:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.