Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <section>
  <h1>Sort elements with <em>ithSort</em> (jQuery plugin)</h1>
  <em>2016/05/24</em>
  <p><a href="http://www.itholics.de/jquery-sortierung" target="_blank">Visit Homepage of <strong>ithSort()</strong></a></p>
  <p>View the <strong>JS Part</strong> for detailed informations!</p>

<h4>Sorting numbers (asc)</h4>
<ol id="numbers">
  <li>48</li>
  <li>78</li>
  <li>135</li>
  <li>78</li>
  <li>4</li>
  <li>-48</li>
  <li>-877</li>
  <li>8774</li>
  <li>10</li>
  <li>0</li>
</ol>

<h4>Sorting numbers (asc) and text (desc) inline, keeping DOM structure</h4>
<ol id="mixed">
  <li class="num">548</li>
  <li class="num">784</li>
  <li class="text">apple</li>
  <li class="num">-78</li>
  <li class="text">orange</li>
  <li class="text">banana</li>
  <li class="num">666</li>
  <li class="text">grapefruit</li>
  <li class="text">citrus</li>
</ol>

<h4>Sorting LI elements numeric (asc) using filter to span container</h4>
<ol id="filters">
  <li><span>10</span></li>
  <li><span>8</span></li>
  <li><span>9</span></li>
  <li><span>1</span></li>
  <li><span>3</span></li>
  <li><span>4</span></li>
  <li><span>2</span></li>
  <li><span>5</span></li>
  <li><span>7</span></li>
  <li><span>6</span></li>
</ol>

<h4>Using function to sort numbers (asc)</h4>
<ol id="function">
  <li><span data-value="10">10</span></li>
  <li><span data-value="8">8</span></li>
  <li><span data-value="9">9</span></li>
  <li><span data-value="1">1</span></li>
  <li><span data-value="3">3</span></li>
  <li><span data-value="4">4</span></li>
  <li><span data-value="2">2</span></li>
  <li><span data-value="5">5</span></li>
  <li><span data-value="7">7</span></li>
  <li><span data-value="6">6</span></li>
</ol>

<h4>Using sort function with inline option</h4>
<ol id="mixedFunctions">
  <li class="sortable"><span data-value="10">10 - sortable</span></li>
  <li><span data-value="8">8</span></li>
  <li><span data-value="9">9</span></li>
  <li><span data-value="1">1</span></li>
  <li class="sortable"><span data-value="3">3 - sortable</span></li>
  <li class="sortable"><span data-value="4">4 - sortable</span></li>
  <li><span data-value="2">2</span></li>
  <li class="sortable"><span data-value="5">5 - sortable</span></li>
  <li><span data-value="7">7</span></li>
  <li class="sortable"><span data-value="6">6 - sortable</span></li>
</ol>
</section>
              
            
!

CSS

              
                body {
  min-width: 400px !important;
  max-width: 80%;
  display: flex;
  justify-content: center;
  background: black url('http://www.easyfreepatterns.com/patterns/21/dark-metallic-background-pattern-tile-able-website-backgrounds-21450.jpg');
  margin: 0;
  background-attachment: fixed;
}

a {
  font-weight: bold;
  color: green;
}

section {
  background: white;
  padding: 0 25px;
  box-shadow: 0 0 15px 3px black;
}

ol > li {
  text-indent: 10px;
  padding: 3px;
}

ol > li:nth-child(odd) {
  background: #eee;
}
              
            
!

JS

              
                // sort LI's numeric and ascending
        $('#numbers li').ithSort({type: 'number'});
        // sort LI's numeric, ascending and inline
        $('#mixed li.num').ithSort({type: 'numbers', inline: true});
        // sort LI's alphanumeric, descending and inline
        $('#mixed li.text').ithSort({by: 'desc', inline: true});
        // sort LI's numeric and ascending by using filter to span content for comparison
        $('#filters li').ithSort({type: 'number', filter: 'span'});
        // sort LI's numeric and ascending using sort function
        $('#function li').ithSort(function(a,b){
            var order = -1; // change to -1 to descending order
            return ( $(a).find('span').attr('data-value') - $(b).find('span').attr('data-value') ) * order;
        });
        // sort LI's numeric and ascending using sort function and inline option
        $('#mixedFunctions li.sortable').ithSort(function(a,b){
            var order = 1; // change to -1 to descending order
            return ( $(a).find('span').attr('data-value') - $(b).find('span').attr('data-value') ) * order;
        }, true);
              
            
!
999px

Console