Sorting a list while keeping its correspondence to another list

With[{p = Ordering[ids]},
 idsnew = ids[[p]];
 valuesnew = values[[p]];
 ]
idsnew
valuesnew

{5, 11, 17, 24, 25, 31, 32, 33, 37, 38, 39, 40}

{0.0351563, 0.131836, 0.086792, 0.0637894, 0.0351563, 0.065752, 0.0146484, 0.0875244, 0.191388, 0.0503769, 0.173784, 0.063796}


I would keep them together while sorting.

SortBy[Transpose[{ids, values}], First]
{{5, 0.0351563}, {11, 0.131836}, {17, 0.086792}, {24, 0.0637894}, {25,
   0.0351563}, {31, 0.065752}, {32, 0.0146484}, {33, 0.0875244}, {37, 
  0.191388}, {38, 0.0503769}, {39, 0.173784}, {40, 0.063796}}

AssociationThread[ids, values] // KeySort

Edit To extract keys and values

sorted = AssociationThread[ids, values] // KeySort
sortedIds = Keys[sorted]
sortedValues = Values[sorted]