What type of a literary device is this? [duplicate]

Solution 1:

It is an example of chiasmus, which is

  1. Repetition of ideas in inverted order
  2. Repetition of grammatical structures in inverted order (not to be mistaken with antimetabole, in which identical words are repeated and inverted).

See here or any other reputable source. (One of my favorites, from which the above is drawn, is Silva Rhetoricae.