Given a list of pairs where the first element of the pair is real values and the second element is an integer, how to obtain a new list of a length n ordered by the second elements being the first element If there is a gap in the ordered integers.
Better using an example:
Initial list:
{{b1,1}, {b3, 4}, {b4, 7}}
Apply a rule to obtain a list of length 10:
Final list:
{{b1,1},{0, 2}, {b2, 3}, {b3, 4}, {0, 5}, {0, 6}, {b4, 7}, {0, 8},{0,9}, {0, 10}}
I have a twisty solution.
list={{b1,1},{b3,4},{b4,7}}
Sort[DeleteDuplicatesBy[Join[list, Transpose[{PadLeft[{0},Last[Last[list]]+1],
Range[0,Last[Last[list]]]}]], Last],#1[[2]]<#2[[2]]&]
Thank you a lot.