Run a command on every line that matches (or doesn't), and sort lines.
4 drills
Delete the noise: Delete every line that the target no longer has, with one :g/pattern/d. Pick a short pattern that only those lines contain.
Keep only the matches: Keep only the lines that match a pattern and delete all the others, with :v/pattern/d.
Move and copy with :g: Combine :g with :m or :t to rearrange lines: :g/^/m0 reverses the file, :g/pat/m$ moves matches to the end, :g/pat/t$ copies them there.
Sort lines: Sort the lines into the order of the target with :sort and the right flag, if any: u (unique), n (by number) or ! (reverse).