which rule did you use for ordering the cube states?
The cube is represented with a permutation of 7 elements and the orientation of 6 elements.
So, the identical cube is this:
1 2 3 4 5 6 7
0 0 0 0 0 0
The order of the elements: UBL,UBR,UFR,UFL,DBR,DFR,DFL (DBL is fixed / always solved). A corner is oriented, if the top/down sticker is actually looking at top/down. 1 is CW, 2 is CCW. Note that the orientation of the 7. corner is uniquely determined by the other 6 (the sum of the seven orientation-numbers must be 0 modulo 3).
So let's see that state when everything is okay, only UBL (1.) and UFR (3.) swapped:
3 2 1 4 5 6 7
0 0 0 0 0 0
Or another one, where everything os solved, but UBR (2.) rotated CW and UFR (3.) rotated CCW:
1 2 3 4 5 6 7
0 1 2 0 0 0
If we apply a U move, that permutes elements from 1 to 4, and leaves the orientation:
4 1 2 3 5 6 7
0 0 0 0 0 0
A more complicated example: after R U, you have this:
4 1 3 6 2 5 7
0 0 1 2 2 2
Look at the 4. column (6, and under it a 2). It means that at the forth position (UFL place) is the 6. corner (DFR), an it is rotated counter-clockwise.
So we need to encode this information into a single number. The oriantiton is very easy: just handle it as a number in base 3. So
0 0 0 0 0 0 = 0
1 0 0 0 0 0 = 1
2 0 0 0 0 0 = 2
0 1 0 0 0 0 = 3
...
1 1 1 1 1 1 = 301
...
2 2 2 2 2 2 = 728
As for the permutation, the number represents a permutation is the ordinal number in a lexicographical ordering. So:
1 2 3 4 5 6 7 = 0
1 2 3 4 5 7 6 = 1
1 2 3 4 6 5 7 = 2
1 2 3 4 6 7 5 = 3
...
7 6 5 4 3 2 1 = 5039
There are algorithms how to calculate this directly. (See more: permutation ranking)
So, for every state, we can generate 2 unique numbers. How can we merge it into a singe number? Easy:
final number = permutation_number * number_of_orientation numbers + orientation_number,
and we know that the number_of_orientation numbers = 3^7 = 729
So:
final number = permutation_number*729 + orientation number
This is a similar trick when you want to get the n-th element of a 2 dimensional matrix: i-th row (i = 0, ..., h-1), j-th column (j = 0, ..., w-1), then the n-th element is i*w + j (or j*h + i, depends on we want the rows first or the columns first).
This goes from 0 to N-1 (N = number of states on a 2x2), so if we want the numbering from 1 to N, we just have to add 1.
The inverse is just as easy (for a given number what is the cube state).
EDIT:
So, the 1. element in the table is the solved:
1 2 3 4 5 6 7
0 0 0 0 0 0
(perm number is 0, orientation is 0)
What could be the second element? The perm number is 0 and the orientation is 1:
1 2 3 4 5 6 7
1 0 0 0 0 0
That means the 7-th cubie has a CCW orientation. So overall, UBL is rotated CW, DFL is rotated CCW, and indeed, its solution is U R' U R' F' R2 U2 F U F'.
And the very last element in the table is:
7 6 5 4 3 2 1
2 2 2 2 2 2