Last active
June 20, 2022 14:50
-
-
Save Jakobud/a0ac11e80a1de453cd86f0d3fc0a1410 to your computer and use it in GitHub Desktop.
Sort a SASS map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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 <[email protected]> | |
@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
Here is a variant that will sort by values.