Index: trunk/src/org/openstreetmap/josm/data/osm/NoteData.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/NoteData.java	(revision 7781)
+++ trunk/src/org/openstreetmap/josm/data/osm/NoteData.java	(revision 7782)
@@ -3,4 +3,6 @@
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.List;
@@ -23,4 +25,62 @@
     private final List<Note> noteList;
     private Note selectedNote = null;
+    private Comparator<Note> comparator = DEFAULT_COMPARATOR;
+
+    /**
+     * Sorts notes in the following order:
+     * 1) Open notes
+     * 2) Closed notes
+     * 3) New notes
+     * Within each subgroup it sorts by ID
+     */
+    public static final Comparator<Note> DEFAULT_COMPARATOR = new Comparator<Note>() {
+        @Override
+        public int compare(Note n1, Note n2) {
+            if (n1.getId() < 0 && n2.getId() > 0) {
+                return 1;
+            }
+            if (n1.getId() > 0 && n2.getId() < 0) {
+                return -1;
+            }
+            if (n1.getState() == State.closed && n2.getState() == State.open) {
+                return 1;
+            }
+            if (n1.getState() == State.open && n2.getState() == State.closed) {
+                return -1;
+            }
+            return Long.valueOf(Math.abs(n1.getId())).compareTo(Long.valueOf(Math.abs(n2.getId())));
+        }
+    };
+
+    /** Sorts notes strictly by creation date */
+    public static final Comparator<Note> DATE_COMPARATOR = new Comparator<Note>() {
+        @Override
+        public int compare(Note n1, Note n2) {
+            return n1.getCreatedAt().compareTo(n2.getCreatedAt());
+        }
+    };
+
+    /** Sorts notes by user, then creation date */
+    public static final Comparator<Note> USER_COMPARATOR = new Comparator<Note>() {
+        @Override
+        public int compare(Note n1, Note n2) {
+            String n1User = n1.getFirstComment().getUser().getName();
+            String n2User = n2.getFirstComment().getUser().getName();
+            if (n1User.equals(n2User)) {
+                return n1.getCreatedAt().compareTo(n2.getCreatedAt());
+            }
+            return n1.getFirstComment().getUser().getName().compareTo(n2.getFirstComment().getUser().getName());
+        }
+    };
+
+    /** Sorts notes by the last modified date */
+    public static final Comparator<Note> LAST_ACTION_COMPARATOR = new Comparator<Note>() {
+        @Override
+        public int compare(Note n1, Note n2) {
+            Date n1Date = n1.getComments().get(n1.getComments().size()-1).getCommentTimestamp();
+            Date n2Date = n2.getComments().get(n2.getComments().size()-1).getCommentTimestamp();
+            return n1Date.compareTo(n2Date);
+        }
+    };
 
     /**
@@ -37,4 +97,5 @@
     public NoteData(List<Note> notes) {
         noteList = notes;
+        Collections.sort(notes, comparator);
         for (Note note : notes) {
             if (note.getId() <= newNoteId) {
@@ -195,4 +256,5 @@
 
     private void dataUpdated() {
+        Collections.sort(noteList, comparator);
         Main.map.noteDialog.setNoteList(noteList);
         Main.map.mapView.repaint();
@@ -217,3 +279,17 @@
         dataUpdated();
     }
+
+    /** @return The current comparator being used to sort the note list */
+    public Comparator<Note> getCurrentSortMethod() {
+        return comparator;
+    }
+
+    /** Set the comparator to be used to sort the note list. Several are available
+     * as public static members of this class.
+     * @param comparator - The Note comparator to sort by
+     */
+    public void setSortMethod(Comparator<Note> comparator) {
+        this.comparator = comparator;
+        dataUpdated();
+    }
 }
Index: trunk/src/org/openstreetmap/josm/gui/NoteSortDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/NoteSortDialog.java	(revision 7782)
+++ trunk/src/org/openstreetmap/josm/gui/NoteSortDialog.java	(revision 7782)
@@ -0,0 +1,88 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.Component;
+import java.util.Comparator;
+
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.notes.Note;
+import org.openstreetmap.josm.data.osm.NoteData;
+
+/**
+ * A dialog to allow the user to choose a sorting method for the list of notes
+ */
+public class NoteSortDialog extends ExtendedDialog {
+
+    private JRadioButton defaultSort = new JRadioButton(tr("Default (open, closed, new)"));
+    private JRadioButton userSort = new JRadioButton(tr("Username"));
+    private JRadioButton dateSort = new JRadioButton(tr("Created date"));
+    private JRadioButton lastActionSort = new JRadioButton(tr("Last change date"));
+
+    /**
+     * Construct a new dialog. The constructor automatically adds a "Cancel" button.
+     * @param parent - Parent component. Usually Main.parent
+     * @param title - Translated text to display in the title bar of the dialog
+     * @param buttonText - Translated text to be shown on the action button
+     */
+    public NoteSortDialog(Component parent, String title, String buttonText) {
+        super(parent, title, new String[] {buttonText, tr("Cancel")});
+    }
+
+    /**
+     * Builds and displays the window to the user.
+     * @param currentSortMode - The current sort mode which will be pre-selected in the list
+     */
+    public void showSortDialog(Comparator<Note> currentSortMode) {
+        JLabel label = new JLabel(tr("Select note sorting method"));
+        if (currentSortMode == NoteData.DEFAULT_COMPARATOR) {
+            defaultSort.setSelected(true);
+        } else if (currentSortMode == NoteData.DATE_COMPARATOR) {
+            dateSort.setSelected(true);
+        } else if (currentSortMode == NoteData.USER_COMPARATOR) {
+            userSort.setSelected(true);
+        } else if (currentSortMode == NoteData.LAST_ACTION_COMPARATOR) {
+            lastActionSort.setSelected(true);
+        } else {
+            Main.warn("sort mode not recognized");
+        }
+
+        ButtonGroup bg = new ButtonGroup();
+        bg.add(defaultSort);
+        bg.add(userSort);
+        bg.add(dateSort);
+        bg.add(lastActionSort);
+
+        JPanel panel = new JPanel();
+        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+        panel.add(label);
+        panel.add(defaultSort);
+        panel.add(userSort);
+        panel.add(dateSort);
+        panel.add(lastActionSort);
+
+        setContent(panel);
+
+        showDialog();
+    }
+
+    /** @return Note comparator that the user has selected */
+    public Comparator<Note> getSelectedComparator() {
+        if (dateSort.isSelected()) {
+            return NoteData.DATE_COMPARATOR;
+        } else if (userSort.isSelected()) {
+            return NoteData.USER_COMPARATOR;
+        } else if (lastActionSort.isSelected()) {
+            return NoteData.LAST_ACTION_COMPARATOR;
+        } else {
+            return NoteData.DEFAULT_COMPARATOR;
+        }
+    }
+}
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/NoteDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/NoteDialog.java	(revision 7781)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/NoteDialog.java	(revision 7782)
@@ -36,4 +36,5 @@
 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
 import org.openstreetmap.josm.gui.NoteInputDialog;
+import org.openstreetmap.josm.gui.NoteSortDialog;
 import org.openstreetmap.josm.gui.SideButton;
 import org.openstreetmap.josm.gui.layer.Layer;
@@ -75,4 +76,5 @@
     private final NewAction newAction;
     private final ReopenAction reopenAction;
+    private final SortAction sortAction;
     private final UploadNotesAction uploadAction;
 
@@ -90,4 +92,5 @@
         newAction = new NewAction();
         reopenAction = new ReopenAction();
+        sortAction = new SortAction();
         uploadAction = new UploadNotesAction();
         buildDialog();
@@ -121,4 +124,5 @@
                 new SideButton(closeAction, false),
                 new SideButton(reopenAction, false),
+                new SideButton(sortAction, false),
                 new SideButton(uploadAction, false)}));
         updateButtonStates();
@@ -144,4 +148,10 @@
             uploadAction.setEnabled(true);
         }
+        //enable sort button if any notes are loaded
+        if (noteData == null || noteData.getNotes().isEmpty()) {
+            sortAction.setEnabled(false);
+        } else {
+            sortAction.setEnabled(true);
+        }
     }
 
@@ -161,13 +171,8 @@
     @Override
     public void layerAdded(Layer newLayer) {
-        if (Main.isDebugEnabled()) {
-            Main.debug("layer added: " + newLayer);
-        }
         if (newLayer instanceof NoteLayer) {
-            if (Main.isDebugEnabled()) {
-                Main.debug("note layer added");
-            }
             noteData = ((NoteLayer)newLayer).getNoteData();
             model.setData(noteData.getNotes());
+            setNoteList(noteData.getNotes());
         }
     }
@@ -364,3 +369,21 @@
         }
     }
+
+    class SortAction extends AbstractAction {
+
+        public SortAction() {
+            putValue(SHORT_DESCRIPTION, tr("Sort notes"));
+            putValue(NAME, tr("Sort"));
+            putValue(SMALL_ICON, ImageProvider.get("dialogs", "sort"));
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            NoteSortDialog sortDialog = new NoteSortDialog(Main.parent, tr("Sort notes"), tr("Apply"));
+            sortDialog.showSortDialog(noteData.getCurrentSortMethod());
+            if (sortDialog.getValue() == 1) {
+                noteData.setSortMethod(sortDialog.getSelectedComparator());
+            }
+        }
+    }
 }
