Opened 5 years ago

# Add default sorting to CC selector plugin

Reported by: Owned by: grimmdude normal CcSelectorPlugin trivial list sort 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)"


### comment:1 Changed 5 years ago by anonymous

• Type changed from defect to enhancement

### comment:2 follow-up: ↓ 3 Changed 5 years ago by hasienda

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 5 years ago by hasienda

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

### Changed 5 years ago by hasienda

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

### Changed 5 years ago by hasienda

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

### Changed 5 years ago by hasienda

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

### comment:3 in reply to: ↑ 2 Changed 5 years ago by hasienda

While the result is certainly not perfect ...

### comment:4 Changed 5 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 4 days ago by rjollos

• Owner hasienda deleted