     # sort tickets.
     #  order: account -> project -> ticket
     ###
-    _sortTickets = (tickets) ->
-      tickets = tickets.sortBy (n) -> n.id
-      tickets = tickets.sortBy (n) -> n.project.id
-      tickets = tickets.sortBy (n) -> n.url
-      return tickets
-
+    _sortTickets: (tickets) ->
+      tickets.sort (a, b) ->
+        if a.url > b.url then return  1
+        if a.url < b.url then return -1
+        if a.project.id > b.project.id then return  1
+        if a.project.id < b.project.id then return -1
+        if a.id > b.id then return  1
+        if a.id < b.id then return -1
+        return 0
+      @_sortSelectedProjectTop(tickets)
+
+
+    ###*
+    # sort tickets by selectedProject.
+    ###
+    _sortSelectedProjectTop: (tickets) ->
+      tickets.sort (a, b) =>
+        isAselected = a.url is @selectedProject.url and a.project.id is @selectedProject.id
+        isBselected = b.url is @selectedProject.url and b.project.id is @selectedProject.id
+        if isAselected is isBselected then return 0
+        if isAselected then return -1
+        if isBselected then return  1
 
   return new DataAdapter
 

    ###
    addTicket: (ticket) ->
      @_tickets.add ticket
      @_tickets.set _sortTickets(@_tickets)
      @fireEvent(@TICKETS_CHANGED, @)

    ###*

    @property 'tickets',
      get: -> @_tickets
      set: (n) ->
        @_sortTickets(n)
        @selectedTicket = n[0]
        @fireEvent(@TICKETS_CHANGED, @)

