How to sort a View according to contextual filters?
The Views Arguments Extras module (for Drupal 7) seems to do what you are looking for. According to the module page, it provides the following:


  Argument Order Sort
  
  a sort handler, that allows for the order of items to be based on
  their order in a multi-value argument


This particular component is ported to Drupal 8: Views Argument Order Sort:


  Using this module will give you a new sort type with a variety of
  options where you can choose what field to apply the argument values
  to for sorting.