Pen Settings



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


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


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.


Save Automatically?

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.


                <p>On initial load, these elements are all out of order.</p>
<div id="container">
  <p id="para1">p1 should be position 2</p>
  <p id="para2">p2 should be position last due to error</p>
  <p id="para3">p3 should be position 5</p>
  <p id="para4">p4 should be position 1</p>
  <p id="para5">p5 should be position 4</p>
  <a id="sortpoint"></a>


                body {
  font-family: monospace;


                //converts items to integers, pushes NaN and (-)infinity to end
//sort will work as intended if the array[0] do not begin with integers, not valuable to fix as no one should be trying to use non-numbers to order, errors will end up last
function sortStringtoNumber(a, b) {
  if(isFinite(parseInt(a[0]) - parseInt(b[0]))) {
    return parseInt(a[0]) - parseInt(b[0]); 
  } else {
    return isFinite(parseInt(a[0])) ? -1 : 1;

//load array[0] as strings to prevent an error with Marketo tokens

var sorter = [
  [" 2", $("#para1") ],
  ["errortest", $("#para2") ],
  ["5 ", $("#para3") ],
  ["1", $("#para4") ],
  ["4", $("#para5") ]

//remove spaces from array[i][0] in case of bad input
for (i = (sorter.length-1); i >= 0; i--) {
  sorter[i][0] = sorter[i][0].replace(/\s+/g, '');


// insertAfter from last of array
for (i = (sorter.length-1); i >= 0; i--) {