title: How to iterate over the values of a set in a specific order when the set is storing user-defined types in swift?
body: <p>So from Swift's documentation, I know:</p>
  
  <blockquote>
    <p>Swift’s Set type does not have a defined ordering. To iterate over the
    values of a set in a specific order, use the sort() method, which
    returns the set’s elements as an array sorted using the <strong>&lt;</strong> operator.</p>
  </blockquote>
  
  <p>I can understand how the sorting works for primitive data types while iterating but is there any way I can make it possible for user defined types? Suppose I have a class called <strong>Foo</strong> which conforms to the hashable protocol (I am not sure if it should be a requirement). Suppose <strong>Foo</strong> has two properties, <strong>ID</strong> and <strong>Username</strong>. </p>
  
  <p>Is it doable? If yes, how can I make it work?</p>