Modify

Opened 8 years ago

Last modified 7 years ago

#1207 new defect

Doesn't appear to sort alphabetically, at least in this particular use case?

Reported by: anonymous Owned by: coderanger
Priority: normal Component: HierWikiPlugin
Severity: major Keywords:
Cc: Trac Release: 0.10

Description

While attempting to use the SubWiki macro, it seems to put the entries in an order that doesn't make any sense to me. I expected them to be in alphabet order.

The macro I used was:

[[SubWiki(UserManual/Vol1/,2)]]

This resulted in (rendered):

  • UserManual/Vol1/Sec1 Introduction
  • UserManual/Vol1/Sec4 Menu Functions
  • UserManual/Vol1/Sec5 Jzz Tools Overview
  • UserManual/Vol1/Sec2 Jzz Overview
  • UserManual/Vol1/Sec3 Jzz Plan View Display

The order I would expect is Sec1, Sec2, Sec3, Sec4, and then Sec5. If instead it sorted by the title of the wiki pages, I would have expected it to be "Introduction", "Jzz Overview", "Jzz Plan View Display", "JZZ Tools Overview", and finally "Menu Functions".

Am I doing something wrong? I have tried grabbing the latest version from trac-hacks and it did not change the behavior. Thanks for any help!!

Attachments (0)

Change History (7)

comment:1 Changed 7 years ago by trac-hacks.org@…

  • Severity changed from normal to major

This is till a problem.

comment:2 Changed 7 years ago by trac-hacks.org@…

*still

comment:3 follow-up: Changed 7 years ago by peter.koerner@…

Currently pages are added to the good_pages-array with the pagename as key and the title as value. then the array is sorted by keys. I'm new to python but MAYBE it will work if you replace in macros/subwiki.py

good_pages.append((p, title)) with good_pages.append((title, p))

put good_pages.sort() before return html.UL(

and replace ) for p,t in good_pages wit ) for t,p in good_pages I'm currently not able to test this because the only trac I have access to is a live system ;)

comment:4 in reply to: ↑ 3 ; follow-up: Changed 7 years ago by anonymous

Replying to peter.koerner@tmp.de:

put good_pages.sort() before return html.UL(

This sorts it on the pagename. (which is fine for me)

To sort on the title, it seems you need to pass a compare function to the sort operation: http://effbot.org/zone/python-list.htm#sorting. But I am also new to python.

comment:5 in reply to: ↑ 4 Changed 7 years ago by anonymous

This sorts it on the pagename. (which is fine for me)

If you also do the other changes I suggested, it should sort on the title, becouse I changed the order of p and t (pagename and title).

comment:6 Changed 7 years ago by aboyko

Confirmed as a problem for me, too. Sorting on pagename would be fine for me, too.

comment:7 Changed 7 years ago by peter.koerner@…

Did you have a look on my suggest obove? I testet it and it works.

Add Comment

Modify Ticket

Action
as new The owner will remain coderanger.
Author


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

 
Note: See TracTickets for help on using tickets.