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.


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.






                function getDigitByPlace(num, i) {
  // return 0 when digit place does not exist i.e. when number has less digits than "i"
  return Math.floor(Math.abs(num)/Math.pow(10, i)) % 10;
function getDigitCount(num) {
  // return new String(num).length;
  return num === 0 ? 1 : Math.floor(Math.log10(Math.abs(num)))+1;
function getLongestNumberLength(arr) {
  let maxLen = 0;
  for(let i=0; i<arr.length; i++) {
    const len = getDigitCount(arr[i]);
    maxLen = len > maxLen
    ? len 
    : maxLen
  return maxLen;

function radixSort(numArray) {
  const maxDigitLen = getLongestNumberLength(numArray);
  // loop by digit palce i.e. from 0 to maxDigitLen-1
  for(let i=0; i<maxDigitLen; i++) {
    //[ [], [], [], ... ] -> 10 empty arrays inside an array called digitBuckets
    const digitBuckets = Array.from({length:10}, () => []);
    // const digitBuckets = Array(10).fill([]); // do not use this
    // looping through the input array to process every element
    for(let j=0; j<numArray.length; j++) {
      const digitAtCurrentPlace = getDigitByPlace(numArray[j], i);
      //console.log(`testing number ${numArray[j]}, digit at place ${i} is ${digitAtCurrentPlace}`)
      //use the digit to place the number in bucket of index equal to the digit
    // modifying the array to change the order after every interation on the input array
    numArray = [].concat(...digitBuckets);
    //console.log('1 full pass complete on input array')
  return numArray;