<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Writing a sort comparison function</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/10/23/55408.aspx</link><description>The rules for sort comparison functions have some interesting consequences.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>RE: Writing a sort comparison function</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/10/23/55408.aspx#55409</link><pubDate>Thu, 23 Oct 2003 22:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:55409</guid><dc:creator>Andy</dc:creator><description>Sorry if this is slightly off-topic, but what is wrong with IComparer?</description></item><item><title>RE: Writing a sort comparison function</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/10/23/55408.aspx#55410</link><pubDate>Thu, 23 Oct 2003 23:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:55410</guid><dc:creator>Israel</dc:creator><description>I would guess that it's because a .Net interface (or a .Net anything) is normally not seen on this blog. See the tagline at top right! :-)</description></item><item><title>RE: Writing a sort comparison function</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/10/23/55408.aspx#55411</link><pubDate>Fri, 24 Oct 2003 16:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:55411</guid><dc:creator>Jonathan</dc:creator><description>The solution to the IComparer for Tasks is too compare another task field after the dependency comparison showed nothing. For instance:
int compare(Task a, Task b) {
  if (a.dependsOn(b)) return 1;
  if (b.dependsOn(a)) return -1;
  return strcmp(a.getName(), b.getName());
  // or return a.getId() - b.getId(); if you don't like the sort order depending on the task name which could change.
}</description></item><item><title>RE: Writing a sort comparison function</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/10/23/55408.aspx#55412</link><pubDate>Fri, 24 Oct 2003 19:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:55412</guid><dc:creator>Raymond Chen</dc:creator><description>Sorry, Jonathan, that still doesn't work. Consider this dependency diagram:

c -&amp;gt; a
b

then a&amp;lt;b (no dependency, use alpha sort), and b&amp;lt;c (no dependency, use alpha sort), and c&amp;lt;a (dependency).</description></item><item><title>I'm Putting On My Top Hat, Tying Up My White Tie, Brushing Out My Tails -- In That Order</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/10/23/55408.aspx#90852</link><pubDate>Wed, 17 Mar 2004 04:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:90852</guid><dc:creator>Fabulous Adventures In Coding</dc:creator><description /></item><item><title>re: Writing a sort comparison function</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/10/23/55408.aspx#208902</link><pubDate>Thu, 05 Aug 2004 13:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:208902</guid><dc:creator>Keith McAfee</dc:creator><description>raymond, you are wrong, &amp;quot;b&amp;lt;c&amp;quot; is incorrect because there IS a dependency of c on b ... dependencies are by definition bi-directional.</description></item><item><title>re: Writing a sort comparison function</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/10/23/55408.aspx#208969</link><pubDate>Thu, 05 Aug 2004 15:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:208969</guid><dc:creator>Raymond Chen</dc:creator><description>The conversion from gotdotnet messed up the formatting.  The diagram should be&lt;br&gt;&lt;br&gt;c -&amp;gt; a&lt;br&gt;b&lt;br&gt;&lt;br&gt;there is no dependency betwen b and anything.&lt;br&gt;&lt;br&gt;With that I'm closing comments since this thread is extremely old.</description></item><item><title>Why do files and directories with no time/date mess up sorting in Explorer?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/10/23/55408.aspx#360196</link><pubDate>Tue, 25 Jan 2005 18:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:360196</guid><dc:creator>The Old New Thing</dc:creator><description>Files and directories with no time/date are often mistaken for so-called </description></item></channel></rss>