QuackatronHQ / Gigarepo

Consider filtering first and then sorting SC-P1003
Performance
Major
a month ago2 years old
Consider filtering first and then sorting
25  def pickFirst2(arr: Array[Int], criteria: Int => Boolean): Option[Int]   =
26    arr.filter(criteria).headOption
27  def pickInAnOrder(arr: Array[Int], criteria: Int => Boolean): Array[Int] =
28    arr.sortWith(_ < _).filter(criteria)29
30  def readFile(path: String): String = Source.fromFile(path).mkString
31