/*
 * Copyright 2000-2011 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.cvsSupport2.cvsBrowser;

import com.intellij.openapi.util.SystemInfo;

import javax.swing.tree.DefaultMutableTreeNode;
import java.util.Comparator;

public class TreeNodeComparator implements Comparator<DefaultMutableTreeNode> {

  public static final TreeNodeComparator INSTANCE = new TreeNodeComparator();

  private TreeNodeComparator() {}

  @Override
  public int compare(DefaultMutableTreeNode node1, DefaultMutableTreeNode node2) {
    if (!SystemInfo.isMac) {
      if (node1 instanceof CvsModule) {
        if (!(node2 instanceof CvsModule)) {
          return -1;
        }
      } else if (node2 instanceof CvsModule) {
        return 1;
      } else if (node1 instanceof CvsFile) {
        if (!(node2 instanceof CvsFile)) {
          return 1;
        }
      } else if (node2 instanceof CvsFile) {
        return -1;
      }
      if (!(node1 instanceof CvsElement)) {
        return 1;
      } else if (!(node2 instanceof CvsElement)) {
        return -1;
      }
    }
    if (node1 instanceof LoadingNode) {
      return 1;
    } else if (node2 instanceof LoadingNode) {
      return -1;
    }
    final String name1 = ((CvsElement)node1).getName();
    final String name2 = ((CvsElement)node2).getName();
    final int result = name1.compareToIgnoreCase(name2);
    if (result != 0) {
      return result;
    }
    return name1.compareTo(name2);
  }
}

@@ -684,16 +684,66 @@
 temInfo;
+%0Aimport com.intellij.openapi.util.text.StringUtil;
 %0A%0Aimport
@@ -1896,138 +1896,48 @@
     
-final int result = name1.compareToIgnoreCase(name2);%0A    if (result != 0) %7B%0A      return result;%0A    %7D%0A    return name1.compareTo(
+return StringUtil.naturalCompare(name1, 
 name

sort cvs tree nodes in natural order