Note that there are some explanatory texts on larger screens.

plurals
  1. POTinysort sort by multiple attributes (more than 1)
    primarykey
    data
    text
    <p>I'm trying to use tinysort as part of a mobile application that I'm building with jquery mobile. My app finds places near a users location and I want to be able to sort results quickly on the fly without having to spend the time re-querying the db.</p> <p>So, what I want to do is be able to use tinysort to re-sort results based on if a user has a favorite place in the area and then by distance, additionally I want to be able to sort by an attribute "beenthere" if the user has marked they've been to a place.</p> <p>This is what I want to do: Sort by favorite:</p> <pre><code>$("ul#places&gt;li").tsort('',({order:"desc",attr:"myfav"},{order:"asc",attr:"dist"})); </code></pre> <p>Sort by Been There:</p> <pre><code>$("ul#places&gt;li").tsort('',({order:"desc",attr:"beenthere"},{order:"asc",attr:"dist"})); </code></pre> <p>Sort by default: // This is easy and works no problem:</p> <pre><code>$("ul#places&gt;li").tsort('',{order:"desc",attr:"dist"}); </code></pre> <p>With a default list order like:</p> <pre><code>&lt;ul id="places"&gt; &lt;li myfav="0" beenthere="0" dist=".02"&gt;Hot Dog Stand&lt;/li&gt; &lt;li myfav="1" beenthere="0" dist=".08"&gt;Joe's Shack&lt;/li&gt; &lt;li myfav="0" beenthere="1" dist=".10"&gt;Frick frack&lt;/li&gt; &lt;li myfav="1" beenthere="1" dist=".15"&gt;Mama's&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Sort by fav should return:</p> <ol> <li>Joe's Shack</li> <li>Mama's</li> <li>Hot Dog Stand</li> <li>Frick frack</li> </ol> <p>Sort by been there should return:</p> <ol> <li>Frick frack</li> <li>Mama's</li> <li>Hot Dog Stand</li> <li>Joe's Shack</li> </ol> <p>And then back to sorting by distance:</p> <ol> <li>Hot Dog Stand</li> <li>Joe's Shack</li> <li>Frick frack</li> <li>Mama's</li> </ol> <p>My calls to tsort above just aren't working with the multiple attribute selectors and either my syntax is wrong or you can't sort on more than one criteria.</p> <p>Any ideas of how I can accomplish this with tsort or other solution is appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload