Modify

Opened 13 years ago

Last modified 13 months ago

#9643 assigned enhancement

Add default sorting to CC selector plugin

Reported by: grimmdude Owned by: Dirk Stöcker
Priority: normal Component: CcSelectorPlugin
Severity: trivial Keywords: list sort
Cc: Trac Release: 0.12

Description

If there are many developers the cc list can get quite long. By simply adding the sorted() function in templates/cc_selector.html on line 31 the names will be alphabetized.

for="d in sorted(cc_developers)"

Attachments (4)

20111230_ccsel_sort_0.png (34.9 KB) - added by Steffen Hoffmann 13 years ago.
Cc list sort: inital state, same for the suggested sort code (does nothing here)
20111230_ccsel_sort_1.png (34.8 KB) - added by Steffen Hoffmann 13 years ago.
Cc list sort: key=lambda dev: dev[1]
20111230_ccsel_sort_2.png (33.8 KB) - added by Steffen Hoffmann 13 years ago.
Cc list sort: key=lambda dev: dev[2]
20111230_ccsel_sort_10.png (35.2 KB) - added by Steffen Hoffmann 13 years ago.
Cc list sort: surrogate key as suggested in my comment:1

Download all attachments as: .zip

Change History (11)

comment:1 Changed 13 years ago by anonymous

Type: defectenhancement

comment:2 Changed 13 years ago by Steffen Hoffmann

Keywords: list sort added

I like simple solutions, nice attempt.

But my test of your code on trunk failed (no noticable change). I use a multi-purpose test environment driven by custom trac-0.13dev here.

Nevertheless I was curious enough to dig deeper into it. I made the code more explicit about what values to use:

for="d in sorted(cc_developers, key=lambda dev: dev[0])

This works since Python2.4, and I could get results for order by user(s full name) and email too. All results show the problem with a simple order on one single field. Because we display username, if user's full name isn't available, it's just too easy. We'll need an equal surrogate key to adapt to the display order, right?

Additionally IMHO the sort should be case-insensitive, because the upper letters forming a separate group looks less intuitive. So my best guess after some fiddling with this is:

for="d in sorted(cc_developers, key=lambda dev:
                 dev[1] and dev[1].lower() or dev[0].lower())

While the result is certainly not perfect in some respect (i.e. order of upper and lower letters per letter), it's an enhancement beyond the current code indeed.

Could you confirm, please? And of course, more suggestions welcome.

Changed 13 years ago by Steffen Hoffmann

Attachment: 20111230_ccsel_sort_0.png added

Cc list sort: inital state, same for the suggested sort code (does nothing here)

Changed 13 years ago by Steffen Hoffmann

Attachment: 20111230_ccsel_sort_1.png added

Cc list sort: key=lambda dev: dev[1]

Changed 13 years ago by Steffen Hoffmann

Attachment: 20111230_ccsel_sort_2.png added

Cc list sort: key=lambda dev: dev[2]

Changed 13 years ago by Steffen Hoffmann

Attachment: 20111230_ccsel_sort_10.png added

Cc list sort: surrogate key as suggested in my comment:1

comment:3 in reply to:  2 Changed 13 years ago by Steffen Hoffmann

Replying to hasienda:

While the result is certainly not perfect ...

Hit by a typo, please see correct link here: the result

comment:4 Changed 13 years ago by anonymous

Thanks very much for your quick and detailed response. I don't know much about the different trac environment versions, but my original solution does work for me. I'm using Trac 0.12

Your fix works good for me as well, so it seems to be the best solution for cross version compatibility. Personally I don't use caps in any of my developer names, but I completely agree that it support for them should be added for people who do.

If you really want to get robust with it you can add a sorting header that, when clicked, reverses the sorting. I can see this being useful for very long lists. I know most users probably don't have lists that long though, but still a nice feature.

Thanks again! -G

comment:5 Changed 8 years ago by Ryan J Ollos

Owner: Steffen Hoffmann deleted

comment:6 Changed 13 months ago by Ryan J Ollos

Owner: set to Dirk Stöcker
Status: newassigned

comment:7 Changed 13 months ago by Dirk Stöcker

Is this still relevant? In my instance the entries are sorted.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as assigned The owner will remain Dirk Stöcker.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.