<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font face="Menlo" class="">func byComparing&lt;T, U: Comparable&gt;(getComparisonKey: (T)-&gt;U) -&gt; (T, T) -&gt; Bool {</font></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font face="Menlo" class="">&nbsp; return { getComparisonKey($0) &lt; getComparisonKey($1) }</font></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font face="Menlo" class="">}</font></div></div></blockquote></div>I've written something similar to bring file URLs into the order of their creation dates.<div class="">It is a small extension for collection types, and its only downside will disappear as soon as properties are accessible via method calls (afair there is a proposal in the making).</div><div class=""><br class=""></div><div class="">It was quite a lot fiddling with generics, and I don't have the tiny piece of code on my own computer, but it works in a way that you can do</div><div class="">let sorted = array.sortUsingAccessor(ElementType.methodThatReturnsComparable)</div><div class="">Beside the problems with properties, I really liked that approach.</div><div class=""><br class=""></div><div class="">Tino</div></body></html>