Here is a sorting problem that I faced during working on Swift 3. I have an Array with many objects called Feed as follows. The sorting method should include 2 steps: - The objects having the same barcode will stand side-by-side in the array - The object having the same barcode having the status A will stand on the left, the next is the one having status B, then the one with status C.
How to write a sort function to cover those two steps ??
class Feed: Object {
dynamic var barcode: Int
dynamic var feed_type = ""
dynamic var status: String
override class func primaryKey() -> String {
return "id"
}
var type: FeedType {
get {
return FeedType.get(feed_type)
}
set(newValue) {
feed_type = newValue.key
}
}
}