There are shorter options in Nim too, depending on your stylistic preferences
let sorted = entries.sorted(proc (a, b: Entry): int = cmp(a.timestamp, b.timestamp))
let sorted = entries.sorted((a, b) => cmp(a.timestamp, b.timestamp))
let sorted = entries.sortedByIt(it.timestamp)
I suppose you could change the whole proc to something like
proc groupIntoThreads(entries: seq[Entry], threshold: int): seq[seq[Entry]] =
let sorted = entries.sortedByIt(it.timestamp)
for i, entry in sorted:
if i == 0 or entry.timestamp - sorted[i - 1].timestamp > threshold:
result.add(@[sorted[i]])
else:
result[^1].add(sorted[i])
What did you find fishy about them? They seem roughly the same, aside from the countries involved with the projects having a bit more local information.
> Even now, a company in many militaries seems like the smallest unit that's somehow "self-contained" or capable of independent operation and logistics in a way neither a platoon or a battalion does.
Do you have company and battalion mixed up here? Why wouldn't a battalion, which consists of companies, be capable of independent operation if the individual companies are?
I suppose you could change the whole proc to something like