Function Repository Resource:

# TupleIndex

Compute the index of a given tuple of non-negative integers

Contributed by: Ed Pegg Jr
 ResourceFunction["TupleIndex"][tuple] returns the index of tuple as it would appear in a list of all integer tuples of the same length, sorted by the maximal element.

## Details and Options

A tuple with largest element n will be ordered after tuples that have all elements less than n.
In case of ties, tuples with largest element n have Sort ordering.

## Examples

### Basic Examples (6)

Get the index of a 3-tuple:

 In[1]:=
 Out[1]=

Get the index of a 3-tuple with a larger element:

 In[2]:=
 Out[2]=

Show by example how element sizes and positions affect ordering:

 In[3]:=
 Out[3]=

Indices of 2-tuples sorted by maximal element:

 In[4]:=
 Out[4]=

Indices of 3-tuples sorted by maximal element:

 In[5]:=
 Out[5]=

Show the tuples as they would be sorted by TupleIndex:

 In[6]:=
 Out[6]=

Find indices of some larger k-tuples:

 In[7]:=
 Out[7]=

### Properties and Relations (2)

Use Tuples to produce 3-tuples sorted by maximal element:

 In[8]:=
 Out[8]=

TupleIndex is based on this ordering:

 In[9]:=
 Out[9]=

### Neat Examples (2)

Find the index of a large 6-tuple:

 In[10]:=
 Out[10]=

Find the index of a large 111-tuple:

 In[11]:=
 Out[11]=

## Version History

• 2.0.0 – 20 December 2019
• 1.0.0 – 02 December 2019