I am trying to sort an array of objects that has a string date field in the from of "MM-DD-YYYY" and a boolean field. I want to create a function that sorts the array by both the date field and by the boolean field. I am having a hard time figuring out how to do this. The done field is default set to false and is not needed in my init func.
var items = [BucketItem(title: "blah", des: "description", lat: 134.6, lon: 27.0, dat: "02-14-2017"),BucketItem(title: "blah", des: "description", lat: 134.6, lon: 27.0, dat: "02-11-2017"), BucketItem(title: "blah blah", des: "description", lat: 134.6, lon: 27.0, dat: "02-9-2017")]
I looked at the .sort
function but I don't how to compare the dates since they are in string format and I also don't know how to sort by two fields rather than just one. I want to sort so that if the boolean is true, then it is automatically less then an item with a boolean field of false. If both booleans are false, then it is sorted by date.