Hi,
I have a question about sorting search result.
I think XWiki uses XWiki.Results to display search result. Furthermore
XWiki.Results use javascript
/xwiki/skins/albatross/scripts/table/tablefilterNsort.js to sort and
filter the rows. However, the date row in the search result may be
sorted incorrectly.
As defined is the XWiki.Results, the Date row format is "yyyy MMM dd
at HH:mm". Thus the the date will show like "2008 Mar 23 at 22:25" or
"2008 Apr 09 at 16:21". If I sort the date row in the search result
in decreasing order, and I expect the result like this:
2008 Apr 09 at 16:21
2008 Mar 23 at 22:25
as Apr > Mar.
Nevertheless, the actual result is opposite.
After checking the code of tablefilterNsort.js, I found there is no
special sort functions in the script. Thus, the date "yyyy MMM dd at
HH:mm" is treated as a normal string.
I think there are two way to solve this problem.
1. change the date format. don't use Apr. use 04 instead.
To to this, you only need to change a word in XWiki.Results.
change $xwiki.formatDate($bentrydoc.date,"yyyy MMM dd") at
$xwiki.formatDate($bentrydoc.date,"HH:mm")
to $xwiki.formatDate($bentrydoc.date,"yyyy MM dd") at
$xwiki.formatDate($bentrydoc.date,"HH:mm")
2. Change script tablefilterNsort.js. Add a special sort function for
the "yyyy MMM dd at HH:mm" format.
I think that's a very small problem. However, I think I should tell you.
WDYT
Sincerely,
Wang Ning