HTMLTable.Sort

35 views
Skip to first unread message

Robert

unread,
Jun 7, 2011, 4:47:17 AM6/7/11
to MooTools Users
String sorting in htmltable is not prepared for localization.
Recently I had to do it and there was two options:
- convert localized string to ascii sortable string
- change the HTMLTable.Sort source (refactor) to allow including of
different sorting functions.

I followed first path (http://jsfiddle.net/6a3Kq/) but I still believe
the second one is better.
It would only need small change in source:
var sorter = parser.sorter;
if (!sorter){

var data = this.parseData(parser).sort(function(a, b){
if (a.value === b.value) return 0;
return a.value > b.value ? 1 : -1;
});

Robert

unread,
Jun 7, 2011, 4:49:15 AM6/7/11
to MooTools Users
String sorting in htmltable is not prepared for localization.
Recently I had to do it and there was two options:
- convert localized string to ascii sortable string
- change the HTMLTable.Sort source (refactor) to allow including of
different sorting functions.

I followed first path (http://jsfiddle.net/6a3Kq/) but I still believe
the second one is better.
It would only need small change in source (here:
https://github.com/mootools/mootools-more/blob/master/Source/Interface/HtmlTable.Sort.js#L219):

var sorter = parser.sorter;
if (!sorter){
sorter = function(a, b){
if (a.value === b.value) return 0;
return a.value > b.value ? 1 : -1;
}
}
var data = this.parseData(parser).sort(sorter);

What do You think?

Aaron Newton

unread,
Jun 14, 2011, 4:14:03 AM6/14/11
to mootool...@googlegroups.com
Please post a bug in lighthouse for this; the forums is a poor place for us to try and keep up with issues.

Robert

unread,
Jun 16, 2011, 3:37:53 AM6/16/11
to MooTools Users
I didn,t see it as a bug, I just wanted to discuss it :-)

Aaron Newton

unread,
Jun 16, 2011, 11:20:42 AM6/16/11
to mootool...@googlegroups.com
That's fine, but if you think you've found something wrong, you should open a ticket anyway. It's how we know what is and isn't working.

Robert

unread,
Jun 21, 2011, 6:08:31 AM6/21/11
to MooTools Users
I will try to send You a pull request, only need to lern git and get
an account on github ;-)

Aaron Newton

unread,
Jun 21, 2011, 12:02:57 PM6/21/11
to mootool...@googlegroups.com
Learning opportunities are awesome!

Robert

unread,
Jun 30, 2011, 8:59:04 AM6/30/11
to MooTools Users
Just did. ;)

Aaron Newton

unread,
Jun 30, 2011, 10:49:56 PM6/30/11
to MooTools Users
I'm not sure how this solves the issue, or even what the issue,
specifically is. This is part of why I've suggested that you open a
ticket. We don't deal with issues here on the mailing list. A pull
request is awesome, we love that stuff, but it's not clear, on its
own, what this is trying to fix. There's no example of what's not
working and how this change makes it work better.

Step 1: open a ticket and describe the issue, ideally including a
jsfiddle that demonstrates the shortcoming.
Step 2: identify the problem and suggest a change (optional)
Step 3: send a pull request with a change that references the ticket
(optional)

Here you've skipped to step 3. It's really awesome that you want to
help out, but you NEED to start with Step 1 - it's the one thing that
ISN'T optional.

That said, what I THINK you're suggesting is that parsers need to have
optional sorting functions in addition to matches. I don't disagree
with this, but it's not clear how pulling your suggested change will
solve things for the existing parsers. Do we need to alter all the
included parsers, too? Stuff like this matters, and it's the stuff
we'd discuss IN THE TICKET. So, please, go back to step one and then
work from there.

-aaron

On Jun 7, 1:49 am, Robert <forpoc...@gmail.com> wrote:
> String sorting in htmltable is not prepared for localization.
> Recently I had to do it and there was two options:
> - convert localized string to ascii sortable string
> - change the HTMLTable.Sort source (refactor) to allow including of
> different sorting functions.
>
> I followed first path (http://jsfiddle.net/6a3Kq/) but I still believe
> the second one is better.
> It would only need small change in source (here:https://github.com/mootools/mootools-more/blob/master/Source/Interfac...

Robert

unread,
Jul 2, 2011, 12:12:37 PM7/2/11
to MooTools Users
Pull requests are visible on the "issues" page - but anyway, I added
an issue with sample and explanation.
Reply all
Reply to author
Forward
0 new messages