In ArcObjects there is possibility to perform custom sorting using ITableSortCallBack:
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">class</SPAN> <SPAN class="token class-name">CustomTableSort</SPAN> <SPAN class="punctuation token">:</SPAN> ITableSortCallBack
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">int</SPAN> <SPAN class="token function">Compare</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">object</SPAN> value1<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">object</SPAN> value2<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">int</SPAN> fieldIndex<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">int</SPAN> fieldSortIndex<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// Do something</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
ITableSort tableSort <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">TableSortClass</SPAN>
<SPAN class="punctuation token">{</SPAN>
Table <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">,</SPAN>
Fields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">,</SPAN>
Compare <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">CustomTableSort</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>But unfortunately geometries are not passed to the Compare method. So now there is no easy way to perform custom sort by some spatial criteria out-of-the-box. Developers need write their own sorting algorithms since they cannot use built-in ITableSort interface in this case. It would be great if this limitation of the ITableSortCallBack will be removed.