Le 2013-08-21 22:54, Brad Jorsch (Anomie) a écrit :
On Wed, Aug 21, 2013 at 4:13 PM, Mathieu Stumpf <
psychosl...@culture-libre.org> wrote:

But no, it doesn't, I still generate a randomly ordered wiki table. So,
what did I missed?


Two things:
1. table.sort() only sorts the sequence part of the table. So only the
elements 1-9 in your table, not 0 or A-E.
2. pairs() doesn't process the elements in any particular order; you can see this by printing out the keys as you iterate through using pairs(). You'd need to use ipairs instead (which again only does the sequence part
of the table).

So as I understand it, I will have to create a new table indexed with integers, using pairs, then sort this "itable", before using ipairs on it. It looks to me like something which may be of real common use, so maybe integrating a function in the mw.* library may be interesting. On the other hand may be I'm just not acustomed with the idiomatic way to build lua code and one may suggest me to
architecture my code in an other way.

--
Association Culture-Libre
http://www.culture-libre.org/

_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to