Generate ordered binary combinations without repetitions
Ruby, 72 bytes

p [0,1].repeated_permutation(n).sort_by{|x|x.count 1}[i].join('').to_i 2


How it works:

irb(main):001:0&gt; [0, 1].repeated_permutation(3).to_a  # generate permutations
=&gt; [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1],
    [1, 1, 0], [1, 1, 1]]

irb(main):002:0&gt; _.sort_by {|x| x.count 1 }           # sort by number of 1's
=&gt; [[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [1, 0, 1],
    [1, 1, 0], [1, 1, 1]]

irb(main):003:0&gt; _[2].join ''  # convert array of binary digits to string
=&gt; "010"
irb(main):004:0&gt; _.to_i 2      # interpret string as binary number
=&gt; 2