Index: FilteredListModel.java
===================================================================
--- FilteredListModel.java	(revision 43982)
+++ FilteredListModel.java	(revision 43983)
@@ -12,15 +12,17 @@
 import javax.swing.SwingUtilities;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.gvsig.expressionevaluator.swing.Element.ConstantElement;
+import org.gvsig.tools.swing.api.ListElement;
 
 /**
  *
  * @author jjdelcerro
  */
 class FilteredListModel extends AbstractListModel {
-    
-    private List<Object> elements;
-    private List<Object> filteredElements;
+
+    private List<ListElement> elements;
+    private List<ListElement> filteredElements;
     private String filter;
 
     public FilteredListModel() {
@@ -39,7 +41,7 @@
         return this.filteredElements.get(index);
     }
 
-    void addElement(String element) {
+    void addElement(ListElement element) {
         this.elements.add(element);
         if (this.elements != this.filteredElements) {
             this.filteredElements.add(element);
@@ -51,56 +53,89 @@
             this.filter = null;
             this.filteredElements = this.elements;
         } else {
+            this.filter = filter;
             this.filteredElements = new ArrayList<>();
-            for (Object element : elements) {
-                if (FilenameUtils.wildcardMatch(element.toString(), this.filter)) {
+            for (ListElement element : elements) {
+                if (FilenameUtils.wildcardMatch(element.getValue().toString().toLowerCase(), this.filter.toLowerCase())) {
                     this.filteredElements.add(element);
                 }
             }
         }
+        fireContentsChanged();
+    }
+
+    private void fireContentsChanged() {
+        if( !SwingUtilities.isEventDispatchThread() ) {
+            SwingUtilities.invokeLater(new Runnable() {
+                @Override
+                public void run() {
+                    fireContentsChanged();
+                }
+            });
+            return;
+        }
         this.fireContentsChanged(this, 0, this.filteredElements.size());
+     }
+
+    public String getFilter() {
+        return this.filter;
     }
+
+    public void sort(final boolean ascending) {
+//        this.sortForeground(ascending);
+        this.sortBackground(ascending);
+    }
     
-    public void sort(final boolean ascending) {
+    private void sortBackground(final boolean ascending) {
         Thread th = new Thread(new Runnable() {
             @Override
             public void run() {
-                final List<Object> items = new ArrayList(elements);
-                items.sort(new Comparator<Object>() {
-                    @Override
-                    public int compare(Object o1, Object o2) {
-                        int r;
-                        if( o1 == null && o2 == null ) {
-                           r = 0;
-                        } else if( o1 == null && o2 != null ) {
-                            r = -1;
-                        } else if( o1 != null && o2 == null ) {
-                            r = 1;
-                        } else {
-                            r = o1.toString().compareTo(o2.toString());
-                        }
-                        if( ascending ) {
-                            return r;
-                        }
-                        return r * -1;
-                    }
-                });
-                SwingUtilities.invokeLater(new Runnable() {
-                    @Override
-                    public void run() {
-                        elements = items;
-                        if( filter!=null ) {
-                            setFilter(filter);
-                        }
-                    }
-                });
+                sortForeground(ascending);
             }
         }, "FilteredListModelSorter");
         th.start();
     }
 
-    public String getFilter() {
-        return this.filter;
+    private void sortForeground(final boolean ascending) {
+        final List<ListElement> items = new ArrayList<>(elements);
+        final Comparator comparator = ComparatorUtils.naturalComparator();
+        items.sort(new Comparator<ListElement>() {
+            @Override
+            public int compare(ListElement o1, ListElement o2) {
+                int r;
+                if (o1 == null && o2 == null) {
+                    r = 0;
+                } else if (o1 == null && o2 != null) {
+                    r = -1;
+                } else if (o1 != null && o2 == null) {
+                    r = 1;
+                } else {
+                    if( o1.getValue() instanceof ConstantElement ) {
+                        r = comparator.compare(
+                            ((ConstantElement)o1.getValue()).getValue(),
+                            ((ConstantElement)o2.getValue()).getValue()
+                        );
+                    } else {
+                        r = comparator.compare(o1.getValue(),o2.getValue());
+                    }
+                }
+                if (ascending) {
+                    return r;
+                }
+                return r * -1;
+            }
+        });
+        elements = items;
+        filteredElements = elements;
+        if (filter != null) {
+            setFilter(filter);
+        } else {
+            fireContentsChanged();
+        }
     }
-    
+
+    void addElement(Object data) {
+        ListElement e = new ListElement(data.toString(), data);
+        this.addElement(e);
+    }
 }
