<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AOrdered_pairs</id>
	<title>Module:Ordered pairs - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AOrdered_pairs"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Ordered_pairs&amp;action=history"/>
	<updated>2026-08-03T09:19:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Ordered_pairs&amp;diff=144177&amp;oldid=prev</id>
		<title>imported&gt;Gonnym: ←Created page with &#039;local p = {}  local function __genOrderedIndex(t)     local orderedIndex = {}     for key in pairs(t) do         table.insert(orderedIndex, key)     end     table.sort(orderedIndex)     return orderedIndex end  local function orderedNext(t, state)     -- Equivalent of the next function, but returns the keys in the alphabetic     -- order. We use a temporary ordered key table that is stored in the     -- table being iterated.      local key = nil     if stat...&#039;</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Ordered_pairs&amp;diff=144177&amp;oldid=prev"/>
		<updated>2021-12-23T10:31:00Z</updated>

		<summary type="html">&lt;p&gt;&lt;a href=&quot;/index.php?title=WP:AES&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;WP:AES (page does not exist)&quot;&gt;←&lt;/a&gt;Created page with &amp;#039;local p = {}  local function __genOrderedIndex(t)     local orderedIndex = {}     for key in pairs(t) do         table.insert(orderedIndex, key)     end     table.sort(orderedIndex)     return orderedIndex end  local function orderedNext(t, state)     -- Equivalent of the next function, but returns the keys in the alphabetic     -- order. We use a temporary ordered key table that is stored in the     -- table being iterated.      local key = nil     if stat...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
local function __genOrderedIndex(t)&lt;br /&gt;
    local orderedIndex = {}&lt;br /&gt;
    for key in pairs(t) do&lt;br /&gt;
        table.insert(orderedIndex, key)&lt;br /&gt;
    end&lt;br /&gt;
    table.sort(orderedIndex)&lt;br /&gt;
    return orderedIndex&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function orderedNext(t, state)&lt;br /&gt;
    -- Equivalent of the next function, but returns the keys in the alphabetic&lt;br /&gt;
    -- order. We use a temporary ordered key table that is stored in the&lt;br /&gt;
    -- table being iterated.&lt;br /&gt;
&lt;br /&gt;
    local key = nil&lt;br /&gt;
    if state == nil then&lt;br /&gt;
        -- the first time, generate the index&lt;br /&gt;
        t.__orderedIndex = __genOrderedIndex(t)&lt;br /&gt;
        key = t.__orderedIndex[1]&lt;br /&gt;
    else&lt;br /&gt;
        -- fetch the next value&lt;br /&gt;
        for i = 1, #(t.__orderedIndex) do&lt;br /&gt;
            if t.__orderedIndex[i] == state then&lt;br /&gt;
                key = t.__orderedIndex[i + 1]&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if key then&lt;br /&gt;
        return key, t[key]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- no more value to return, cleanup&lt;br /&gt;
    t.__orderedIndex = nil&lt;br /&gt;
    return&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.orderedPairs(t)&lt;br /&gt;
    -- Equivalent of the pairs() function on tables. Allows to iterate in order.&lt;br /&gt;
    return orderedNext, t, nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Gonnym</name></author>
	</entry>
</feed>