<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>D-talk (Entries tagged as ul)</title>
    <link>http://blog.dynom.nl/</link>
    <description>The little things that pop into mind</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.2-beta4 - http://www.s9y.org/</generator>
    
    

<item>
    <title>Sorting of lists in jQuery</title>
    <link>http://blog.dynom.nl/archives/Sorting-of-lists-in-jQuery_20091006_49.html</link>
            <category>Javascript</category>
    
    <comments>http://blog.dynom.nl/archives/Sorting-of-lists-in-jQuery_20091006_49.html#comments</comments>
    <wfw:comment>http://blog.dynom.nl/wfwcomment.php?cid=49</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.dynom.nl/rss.php?version=2.0&amp;type=comments&amp;cid=49</wfw:commentRss>
    

    <author>nospam@example.com (Mark van der Velden)</author>
    <content:encoded>
    &lt;p&gt;A while back I posted a simple sorting algorithm for number sorting, but it doesn&#039;t really do the trick for regular strings (e.g. anchors). But since I needed one recently I wrote another small and very simple sorting solution. &lt;/p&gt;&lt;p&gt;For a working example, see: &lt;a onclick=&quot;javascript: pageTracker._trackPageview(&#039;/extlink/dynom.nl/jquery/listsort.php&#039;);&quot;  href=&quot;http://dynom.nl/jquery/listsort.php&quot; mce_href=&quot;http://dynom.nl/jquery/listsort.php&quot;&gt;http://dynom.nl/jquery/listsort.php&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;div class=&quot;javascript&quot; style=&quot;text-align: left&quot;&gt;My.&lt;span style=&quot;color: #006600;&quot;&gt;List&lt;/span&gt; = &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; Sort : &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;listSelector&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; sortedElements, left, right;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// If we have any list items to sort on&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;$&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;listSelector + &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039; li&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;length&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// Remove the items from the DOM&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; sortedElements = $&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;listSelector + &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039; li&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;remove&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// Sort, using a custom sorting and compare by anchor contents&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; sortedElements.&lt;span style=&quot;color: #006600;&quot;&gt;sort&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;a, b&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; left = $&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;a&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;children&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;a&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; right = $&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;b&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;children&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;a&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;left &amp;gt; right&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;1&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;right &amp;lt; left&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;return&lt;/span&gt; -&lt;span style=&quot;color: #CC0000;&quot;&gt;1&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// Place the items back on the DOM&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; $&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;listSelector&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;sortedElements&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;/div&gt;&lt;/p&gt;&lt;p&gt;Again, the source should be self explanatory&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Tue, 06 Oct 2009 13:00:00 +0200</pubDate>
    <guid isPermaLink="false">http://blog.dynom.nl/archives/guid_20091006_49.html</guid>
    <category>anchor</category>
<category>filter</category>
<category>javascript</category>
<category>jquery</category>
<category>link</category>
<category>list</category>
<category>sort</category>
<category>ul</category>

</item>
<item>
    <title>Javascript unordened list sorting</title>
    <link>http://blog.dynom.nl/archives/Javascript-unordened-list-sorting_20090511_36.html</link>
            <category>Javascript</category>
    
    <comments>http://blog.dynom.nl/archives/Javascript-unordened-list-sorting_20090511_36.html#comments</comments>
    <wfw:comment>http://blog.dynom.nl/wfwcomment.php?cid=36</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://blog.dynom.nl/rss.php?version=2.0&amp;type=comments&amp;cid=36</wfw:commentRss>
    

    <author>nospam@example.com (Mark van der Velden)</author>
    <content:encoded>
    &lt;p&gt;I spent some time figuring out a way to sort unordened lists, when dynamically (AJAX) adding/removing items. I had some problems with the typical &#039;10 being greater then 1, but lesser then 2&#039;, so I took a simple bubblesort algorithm and tweaked it with the string length. It&#039;s probably not the fastest or most elegant way of doing it, but it works like a charm. If you have any improvement points, don&#039;t be shy and drop a line. &lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;b&gt;The algorithm:&lt;/b&gt;&lt;br /&gt;
This is the search algorithm I used, (which I found &lt;a onclick=&quot;javascript: pageTracker._trackPageview(&#039;/extlink/www.merlyn.demon.co.uk/js-order.htm&#039;);&quot;  href=&quot;http://www.merlyn.demon.co.uk/js-order.htm&quot; mce_href=&quot;http://www.merlyn.demon.co.uk/js-order.htm&quot;&gt;here&lt;/a&gt;) and I simply added the difference in string length to the equation to make sure that &#039;10&#039; is greater then &#039;1&#039;, causing human-natural sorting.&lt;/p&gt;&lt;p&gt;
&lt;div class=&quot;javascript&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// Search algorithm, if lesser then 0 it&#039;s smaller then the current item.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// If it&#039;s greater then 0, it&#039;s &amp;quot;larger&amp;quot; then the current item.&lt;/span&gt;&lt;br /&gt;cmpr =&amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;newItem &amp;gt; curListItem&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; - &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;curListItem &amp;gt; newItem&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; +&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;newItem.&lt;span style=&quot;color: #006600;&quot;&gt;length&lt;/span&gt; - curListItem.&lt;span style=&quot;color: #006600;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;Before:&lt;/b&gt; Title 1, Title 10, Title 13, Title 2, Title 3, Title 4&lt;br /&gt;
&lt;b&gt;After:&lt;/b&gt; Title 1, Title 2, Title 3, Title 4, Title 10, Title 13
&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;Read on to see a implementation example...&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://blog.dynom.nl/archives/Javascript-unordened-list-sorting_20090511_36.html#extended&quot;&gt;Continue reading &quot;Javascript unordened list sorting&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 11 May 2009 15:19:35 +0200</pubDate>
    <guid isPermaLink="false">http://blog.dynom.nl/archives/guid_20090511_36.html</guid>
    <category>ajax</category>
<category>bubble sort</category>
<category>javascript</category>
<category>jquery</category>
<category>li</category>
<category>natural sort</category>
<category>ul</category>
<category>unordened list</category>

</item>

</channel>
</rss>