title: getting A set into a sorted array perl
body: <p>I have been looking for a way to convert a set into a sorted array. </p>
  
  <p>I have found a solution but it seems a little bit rediculous: </p>
  
  <pre><code>use Set::Scalar;
  Set::Scalar-&gt;as_string_callback(sub{join("\n", sort $_[0]-&gt;elements)});
  #above formats print so that a line is added between each element
  ... #assume things are added to the set in this code
  my @arr = split("\n", "$set"); #array contains each sorted element of the set 
  </code></pre>
  
  <p>my only issue is that in my eyes this shouldn't be a fast/memory efficient method of doing this. Please let me know if you have any advice. Thank you in advance. </p>