title: How to sort objects by its enum value?
body: <p>I've got <code>Workout</code> class with <code>Difficulty</code> property</p>
  
  <pre><code>enum Difficulty: String {
    case easy = "easy"
    case moderate = "moderate"
    case hard = "hard"
  }
  
  class Workout {
    var name: String?
    var difficulty: Difficulty?
    .
    .
    .
  }
  </code></pre>
  
  <p>I'd like to sort an array of workouts by the difficulty property. I know I can achieve that by assigning enum's raw value to Int value and compare these values as follows:</p>
  
  <pre><code>data.sort { $0.workout.difficulty!.rawValue &lt; $1.workout.difficulty!.rawValue }
  </code></pre>
  
  <p>But I really want this enum to store string, since it's convenient to assign it to label text down the line without ugly switch-case hacks, and be comparable in some way.</p>
  
  <p>How to achieve that?</p>