Last active
December 12, 2016 16:31
-
-
Save chriswebb09/724e698343791f6990107cf83be371e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct EntryStruct { | |
var name: [String] | |
var id: String | |
} | |
var separateSocial = records.flatMap { [$0.components(separatedBy: ":")] }.map { $0 } | |
var separateName = separateSocial.flatMap { EntryStruct(name: $0.first!.components(separatedBy: ","), id: $0.last!)} | |
var ids = [String]() | |
var updatedEntries = [EntryStruct]() | |
func addToRecords(record:EntryStruct) { | |
if !ids.contains(record.id) { | |
ids.append(record.id) | |
updatedEntries.append(record) | |
} | |
} | |
func checkEntry() { | |
let sortedArray = separateName.sorted { | |
$0.id >= $1.id | |
} | |
let test = sortedArray.sorted { $0.name[0] <= $1.name[0] } | |
test.forEach { | |
if ($0.name[0].components(separatedBy: " ").count >= 3) && $0.name[0].components(separatedBy: ".").count <= 1 { | |
addToRecords(record: $0) | |
} | |
if $0.name[0].components(separatedBy: " ").count == 2 && !ids.contains($0.id) && $0.name[0].components(separatedBy: ".").count <= 1 { | |
addToRecords(record: $0) | |
} | |
} | |
test.forEach { | |
if $0.name.count == 1 { | |
addToRecords(record: $0) | |
} | |
} | |
updatedEntries.forEach { | |
print("\($0.name[0]):\($0.id)") | |
} | |
} | |
checkEntry() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment