Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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|improve this question

1 Answer 1

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|improve this answer
    
Exactly what I was looking for, thanks! –  skerit Nov 26 '11 at 10:07

Your Answer

 
discard

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.