'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

function sortObjectByKey(obj) {
  if (!obj) {
    return obj;
  }
  var list = Object.keys(obj).map(function (key) {
    return {
      value: obj[key],
      key: key
    };
  });
  list.sort(function (a, b) {
    if (a.key < b.key) return -1;
    if (a.key > b.key) return 1;
    return 0;
  });
  var result = list.reduce(function (acc, item) {
    acc[item.key] = item.value;
    return acc;
  }, {});
  return result;
}

exports.sortObjectByKey = sortObjectByKey;
