Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

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.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                let tl = gsap.timeline()
.add("milk", 1)
.add("cookies", 2)
.add("beans", 3)
.add("rice", 4)

let labels = tl.labels
console.log("Object form: ", labels);

// sorting comes from this SO post: https://stackoverflow.com/q/1069666/2065702

// Sort object by value and put in array
const labelsArray = Object.keys(labels).sort(function(a,b){return labels[a]-labels[b]});
console.log("Sorted Array form: ", labelsArray);

// array of objects based on original object
function sortObject(obj) {
    var arr = [];
    for (var prop in obj) {
        if (obj.hasOwnProperty(prop)) {
            arr.push({
                'key': prop,
                'value': obj[prop]
            });
        }
    }
    arr.sort(function(a, b) { return a.value - b.value; });
    //arr.sort(function(a, b) { a.value.toLowerCase().localeCompare(b.value.toLowerCase()); }); //use this to sort as strings
    return arr; // returns array
}
const labelsObjArr = sortObject(labels);
console.log("Sorted array of objects: ", labelsObjArr);

//console.log("first label is " + )
//console.log("second label is " + )
//console.log("last label is " + )
//console.log("number of labels is " + )

              
            
!
999px

Console