title: How to find object with smallest property value in a Swift object array?
body: <p>I have the following Object Array for the Place class:</p>
  <pre><code>class Place: NSObject {
      var distance:Double = Double()
      init(_ distance: Double) {
          self.distance = distance
      }
  }
  
  
  let places = [Place(1.5), Place(8.4), Place(4.5)]
  </code></pre>
  <p>I need to get the Place with the minimum distance.
  I tried using</p>
  <pre><code>let leastDistancePlace = places.min { $0.distance &gt; $1.distance }
  </code></pre>
  <p>as per <a href="https://stackoverflow.com/a/41217004/4858605">this</a> answer for a similar question, but it gave the following error.</p>
  <blockquote>
  <p>Contextual closure type '(Place) -&gt; _' expects 1 argument, but 2 were
  used in closure body</p>
  </blockquote>
  <p><strong>PS:</strong></p>
  <p>As per @robmayoff 's answer, I tried the following in a playground, but I keep getting an error:</p>
  <blockquote>
  <p>value of Type [Place] no member min</p>
  </blockquote>
  <p>Please check this screenshot.
  <a href="https://i.stack.imgur.com/9BNSC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9BNSC.png" alt="enter image description here" /></a></p>
  <p>My swift version is : Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)</p>