Skip to content

Instantly share code, notes, and snippets.

@hashchange
Forked from Jakobud/_map-sort.scss
Created March 16, 2018 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hashchange/7cd4163cf82c76503033eac8e5cb23be to your computer and use it in GitHub Desktop.
Save hashchange/7cd4163cf82c76503033eac8e5cb23be to your computer and use it in GitHub Desktop.
Sort a SASS map
/// map-sort
/// Sort map by keys
/// @param $map - A SASS map
/// @returns A SASS map sorted by keys
/// @requires function list-sort
/// @author Jake Wilson <jake.e.wilson@gmail.com>
@function map-sort($map) {
$keys: list-sort(map-keys($map));
$sortedMap: ();
@each $key in $keys {
$sortedMap: map-merge($sortedMap, ($key: map-get($map, $key)));
}
@return $sortedMap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment