Skip to content

Instantly share code, notes, and snippets.

@Jakobud
Last active August 20, 2022 22:09
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jakobud/744b98b629abe018766f6d506a2e92ae to your computer and use it in GitHub Desktop.
Save Jakobud/744b98b629abe018766f6d506a2e92ae to your computer and use it in GitHub Desktop.
Sort a SASS list
/// list-sort
/// Sort a SASS list
/// @param $list - A SASS list
/// @returns A sorted SASS list
/// @requires function list-remove
/// @author Jake Wilson <jake.e.wilson@gmail.com>
@function list-sort($list) {
$sortedlist: ();
@while length($list) > 0 {
$value: nth($list,1);
@each $item in $list {
@if $item < $value {
$value: $item;
}
}
$sortedlist: append($sortedlist, $value, 'space');
$list: list-remove($list, index($list, $value));
}
@return $sortedlist;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment