sortInPlace
groups = groups!.sort { $0.name < $1.name }
. Release sortInPlace. , . sort() .
: - ( OS X Cocoa ):
import Cocoa
class MyObject {
var x: Int?
}
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
var array = [MyObject]()
func applicationDidFinishLaunching(aNotification: NSNotification) {
for x in 0..<100000 {
let object = MyObject()
object.x = x
array.append(object)
}
array.sortInPlace { $0.x < $1.x }
}
...
}