Now I have a long number list, for example
a = {{1020, 3058}, {98, 98}, {599, 600}}; (*just a sample, the list is very very long*)
I want to replace the number with their order in the list. The number 98
is the smallest number so it should be replaced with 1
and so on. After replacement the list a
should be
{{4, 5}, {1, 1}, {2, 3}};
The code I use is
a = {{1020, 3058}, {98, 98}, {599, 600}};
b = Sort@DeleteDuplicates@Flatten@a;
rule = Table[b[[i]] -> i, {i, 1, Length@b}];
a /. rule
or
a = {{1020, 3058}, {98, 98}, {599, 600}};
b = Sort@DeleteDuplicates@Flatten@a;
Cases[a, {x_Integer, y_Integer} :> {Position[b, x][[1, 1]], Position[b, y][[1, 1]]}]
With the increase of the list size, the code above is very time-consuming. I want to know if there some efficient way to realize my need?