SassySort 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +4 -3
- data/README.md +47 -47
- data/lib/SassySort.rb +15 -15
- data/stylesheets/_SassySort.scss +16 -16
- data/stylesheets/algorithms/_bubble-sort.scss +19 -11
- data/stylesheets/algorithms/_comb-sort.scss +31 -21
- data/stylesheets/algorithms/_insertion-sort.scss +22 -12
- data/stylesheets/algorithms/_quick-sort.scss +30 -21
- data/stylesheets/algorithms/_selection-sort.scss +25 -14
- data/stylesheets/algorithms/_shell-sort.scss +30 -18
- data/stylesheets/helpers/_sort.scss +15 -12
- data/stylesheets/helpers/_str-compare.scss +25 -22
- data/stylesheets/helpers/_swap.scss +16 -16
- data/stylesheets/settings/_order.scss +6 -4
- metadata +8 -8
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
* `0.0
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
* `1.0.0`: stable version
|
4
|
+
* `0.0.1`: initial commit
|
data/README.md
CHANGED
@@ -1,47 +1,47 @@
|
|
1
|
-
|
2
|
-
=========
|
3
|
-
|
4
|
-
Here are a couple of ways to sort values (including strings) in Sass (~> 3.3).
|
5
|
-
|
6
|
-
**Disclaimer!** While it can be useful to sort numbers in Sass in case of the making of a modular scale or something, it is rarely the case for strings. The main idea behind this repository is to push Sass' syntax to its limit. Long story short: *because we can*.
|
7
|
-
|
8
|
-
## Available algorithms
|
9
|
-
|
10
|
-
* [Comb sort](http://en.wikipedia.org/wiki/Comb_sort)
|
11
|
-
* [Quick sort](http://en.wikipedia.org/wiki/Quicksort)
|
12
|
-
* [Shell sort](http://en.wikipedia.org/wiki/Shellsort)
|
13
|
-
* [Bubble sort](http://en.wikipedia.org/wiki/Bubble_sort)
|
14
|
-
* [Selection sort](http://en.wikipedia.org/wiki/Selection_sort)
|
15
|
-
* [Insertion sort](http://en.wikipedia.org/wiki/Insertion_sort)
|
16
|
-
|
17
|
-
## Benchmark
|
18
|
-
|
19
|
-
### 50 items long list
|
20
|
-
* quick -> 0.238s / 0.226s / 0.202s / 0.206s / 0.226s => **0.2195s**
|
21
|
-
* comb -> 0.350s / 0.323s / 0.330s / 0.324s / 0.328s => **0.3310s**
|
22
|
-
* shell -> 0.412s / 0.355s / 0.359s / 0.372s / 0.437s => **0.3869s**
|
23
|
-
* insertion -> 0.400s / 0.42s / 0.406s / 0.399s / 0.468s => **0.4185s**
|
24
|
-
* selection -> 0.635s / 0.579s / 0.580s / 0.601s / 0.611s => **0.6012s**
|
25
|
-
* bubble -> 0.976s / 0.830s / 0.802s / 0.824s / 0.936s => **0.8736s**
|
26
|
-
|
27
|
-
### 100 items long list
|
28
|
-
* quick -> 0.592s / 0.547s / 0.569s / 0.541s / 0.548s => **0.5594s**
|
29
|
-
* comb -> 0.946s / 0.903s / 0.897s / 0.902s / 0.905s => **0.9106s**
|
30
|
-
* shell -> 1.413s / 1.435s / 1.425s / 1.489s / 1.408s => **1.4340s**
|
31
|
-
* insertion -> 1.744s / 1.625s / 1.583s / 1.572s / 1.608s => **1.6263s**
|
32
|
-
* selection -> 2.605s / 2.462s / 2.502s / 2.490s / 2.477s => **2.5072s**
|
33
|
-
* bubble -> 3.828s / 3.699s / 3.704s / 3.672s / 3.743s => **3.7292s**
|
34
|
-
|
35
|
-
`quicksort` is well named since it is by far the fastest algorithm: about 3 times faster than `shellsort` and `insertionsort` implementations, 4 times faster than `selectionsort` and 7 times faster than `bubblesort`.
|
36
|
-
|
37
|
-
## Install as a Compass extension
|
38
|
-
|
39
|
-
1. `gem install SassySort`
|
40
|
-
2. Add `require 'SassySort'` to your `config.rb`
|
41
|
-
3. Import it in your stylesheets with `@import 'SassySort'`
|
42
|
-
|
43
|
-
## Credits
|
44
|
-
|
45
|
-
Thanks to [mgechev](https://github.com/mgechev) for [his work on sorting algorithms](https://github.com/mgechev/javascript-algorithms/tree/master/src/sorting) in JavaScript which has been a great help for implementing sorting algorithms in Sass.
|
46
|
-
|
47
|
-
More informations about sorting algorithms at [http://www.sorting-algorithms.com/](http://www.sorting-algorithms.com/).
|
1
|
+
SassySort
|
2
|
+
=========
|
3
|
+
|
4
|
+
Here are a couple of ways to sort values (including strings) in Sass (~> 3.3).
|
5
|
+
|
6
|
+
**Disclaimer!** While it can be useful to sort numbers in Sass in case of the making of a modular scale or something, it is rarely the case for strings. The main idea behind this repository is to push Sass' syntax to its limit. Long story short: *because we can*.
|
7
|
+
|
8
|
+
## Available algorithms
|
9
|
+
|
10
|
+
* [Comb sort](http://en.wikipedia.org/wiki/Comb_sort)
|
11
|
+
* [Quick sort](http://en.wikipedia.org/wiki/Quicksort)
|
12
|
+
* [Shell sort](http://en.wikipedia.org/wiki/Shellsort)
|
13
|
+
* [Bubble sort](http://en.wikipedia.org/wiki/Bubble_sort)
|
14
|
+
* [Selection sort](http://en.wikipedia.org/wiki/Selection_sort)
|
15
|
+
* [Insertion sort](http://en.wikipedia.org/wiki/Insertion_sort)
|
16
|
+
|
17
|
+
## Benchmark
|
18
|
+
|
19
|
+
### 50 items long list
|
20
|
+
* quick -> 0.238s / 0.226s / 0.202s / 0.206s / 0.226s => **0.2195s**
|
21
|
+
* comb -> 0.350s / 0.323s / 0.330s / 0.324s / 0.328s => **0.3310s**
|
22
|
+
* shell -> 0.412s / 0.355s / 0.359s / 0.372s / 0.437s => **0.3869s**
|
23
|
+
* insertion -> 0.400s / 0.42s / 0.406s / 0.399s / 0.468s => **0.4185s**
|
24
|
+
* selection -> 0.635s / 0.579s / 0.580s / 0.601s / 0.611s => **0.6012s**
|
25
|
+
* bubble -> 0.976s / 0.830s / 0.802s / 0.824s / 0.936s => **0.8736s**
|
26
|
+
|
27
|
+
### 100 items long list
|
28
|
+
* quick -> 0.592s / 0.547s / 0.569s / 0.541s / 0.548s => **0.5594s**
|
29
|
+
* comb -> 0.946s / 0.903s / 0.897s / 0.902s / 0.905s => **0.9106s**
|
30
|
+
* shell -> 1.413s / 1.435s / 1.425s / 1.489s / 1.408s => **1.4340s**
|
31
|
+
* insertion -> 1.744s / 1.625s / 1.583s / 1.572s / 1.608s => **1.6263s**
|
32
|
+
* selection -> 2.605s / 2.462s / 2.502s / 2.490s / 2.477s => **2.5072s**
|
33
|
+
* bubble -> 3.828s / 3.699s / 3.704s / 3.672s / 3.743s => **3.7292s**
|
34
|
+
|
35
|
+
`quicksort` is well named since it is by far the fastest algorithm: about 3 times faster than `shellsort` and `insertionsort` implementations, 4 times faster than `selectionsort` and 7 times faster than `bubblesort`.
|
36
|
+
|
37
|
+
## Install as a Compass extension
|
38
|
+
|
39
|
+
1. `gem install SassySort`
|
40
|
+
2. Add `require 'SassySort'` to your `config.rb`
|
41
|
+
3. Import it in your stylesheets with `@import 'SassySort'`
|
42
|
+
|
43
|
+
## Credits
|
44
|
+
|
45
|
+
Thanks to [mgechev](https://github.com/mgechev) for [his work on sorting algorithms](https://github.com/mgechev/javascript-algorithms/tree/master/src/sorting) in JavaScript which has been a great help for implementing sorting algorithms in Sass.
|
46
|
+
|
47
|
+
More informations about sorting algorithms at [http://www.sorting-algorithms.com/](http://www.sorting-algorithms.com/).
|
data/lib/SassySort.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'compass'
|
2
|
-
|
3
|
-
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
4
|
-
Compass::Frameworks.register('SassySort', :path => extension_path)
|
5
|
-
|
6
|
-
# Version is a number. If a version contains alphas, it will be created as a prerelease version
|
7
|
-
# Date is in the form of YYYY-MM-DD
|
8
|
-
module SassySort
|
9
|
-
VERSION = "0.0
|
10
|
-
DATE = "2014-
|
11
|
-
end
|
12
|
-
|
13
|
-
module Sass::Script::Functions
|
14
|
-
|
15
|
-
end
|
1
|
+
require 'compass'
|
2
|
+
|
3
|
+
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
4
|
+
Compass::Frameworks.register('SassySort', :path => extension_path)
|
5
|
+
|
6
|
+
# Version is a number. If a version contains alphas, it will be created as a prerelease version
|
7
|
+
# Date is in the form of YYYY-MM-DD
|
8
|
+
module SassySort
|
9
|
+
VERSION = "1.0.0"
|
10
|
+
DATE = "2014-12-30"
|
11
|
+
end
|
12
|
+
|
13
|
+
module Sass::Script::Functions
|
14
|
+
|
15
|
+
end
|
data/stylesheets/_SassySort.scss
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
// Order to deal with
|
2
|
-
@import "settings/order";
|
3
|
-
|
4
|
-
// Helpers
|
5
|
-
@import "helpers/str-compare";
|
6
|
-
@import "helpers/swap";
|
7
|
-
|
8
|
-
// Sorting algorithms
|
9
|
-
@import "algorithms/comb-sort";
|
10
|
-
@import "algorithms/quick-sort";
|
11
|
-
@import "algorithms/shell-sort";
|
12
|
-
@import "algorithms/bubble-sort";
|
13
|
-
@import "algorithms/selection-sort";
|
14
|
-
@import "algorithms/insertion-sort";
|
15
|
-
|
16
|
-
// Sort function
|
1
|
+
// Order to deal with
|
2
|
+
@import "settings/order";
|
3
|
+
|
4
|
+
// Helpers
|
5
|
+
@import "helpers/str-compare";
|
6
|
+
@import "helpers/swap";
|
7
|
+
|
8
|
+
// Sorting algorithms
|
9
|
+
@import "algorithms/comb-sort";
|
10
|
+
@import "algorithms/quick-sort";
|
11
|
+
@import "algorithms/shell-sort";
|
12
|
+
@import "algorithms/bubble-sort";
|
13
|
+
@import "algorithms/selection-sort";
|
14
|
+
@import "algorithms/insertion-sort";
|
15
|
+
|
16
|
+
// Sort function
|
17
17
|
@import "helpers/sort";
|
@@ -1,11 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
@
|
11
|
-
|
1
|
+
/// Bubble sort
|
2
|
+
/// @access private
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
/// @param {List} $list - list to sort
|
5
|
+
/// @param {List} $order ($default-order) - order to use for sorting
|
6
|
+
/// @return {List}
|
7
|
+
/// @require {function} _str-compare
|
8
|
+
/// @require {function} _swap
|
9
|
+
@function bubble-sort($list, $order: $default-order) {
|
10
|
+
@for $i from 1 through length($list) {
|
11
|
+
@for $j from $i through 1 {
|
12
|
+
@if $j > 1 and _str-compare(nth($list, $j), nth($list, $j - 1), $order) {
|
13
|
+
$list: _swap($list, $j, $j - 1);
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
@return $list;
|
19
|
+
}
|
@@ -1,21 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
1
|
+
/// Comb sort
|
2
|
+
/// @access private
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
/// @param {List} $list - list to sort
|
5
|
+
/// @param {List} $order ($default-order) - order to use for sorting
|
6
|
+
/// @return {List}
|
7
|
+
/// @require {function} _str-compare
|
8
|
+
/// @require {function} _swap
|
9
|
+
@function comb-sort($list, $order: $default-order) {
|
10
|
+
$gap: length($list);
|
11
|
+
$shrink: 1.3;
|
12
|
+
$swapped: false;
|
13
|
+
|
14
|
+
@while $gap != 1 or $swapped != false {
|
15
|
+
$gap: floor($gap / $shrink);
|
16
|
+
@if $gap < 1 { $gap: 1 }
|
17
|
+
$i: 1;
|
18
|
+
$swapped: false;
|
19
|
+
|
20
|
+
@while $i + $gap <= length($list) {
|
21
|
+
@if not _str-compare(nth($list, $i), nth($list, $i + $gap), $order) {
|
22
|
+
$list: _swap($list, $i, $i + $gap);
|
23
|
+
$swapped: true;
|
24
|
+
}
|
25
|
+
$i: $i + 1;
|
26
|
+
}
|
27
|
+
|
28
|
+
}
|
29
|
+
|
30
|
+
@return $list;
|
31
|
+
}
|
@@ -1,12 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
/// Insertion sort
|
2
|
+
/// @access private
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
/// @param {List} $list - list to sort
|
5
|
+
/// @param {List} $order ($default-order) - order to use for sorting
|
6
|
+
/// @return {List}
|
7
|
+
/// @require {function} _str-compare
|
8
|
+
@function insertion-sort($list, $order: $default-order) {
|
9
|
+
@for $i from 1 through length($list) {
|
10
|
+
$current: nth($list, $i);
|
11
|
+
$j: $i - 1;
|
12
|
+
|
13
|
+
@while $j > 0 and not _str-compare(nth($list, $j), $current, $order) {
|
14
|
+
$list: set-nth($list, $j + 1, nth($list, $j));
|
15
|
+
$j: $j - 1;
|
16
|
+
}
|
17
|
+
|
18
|
+
$list: set-nth($list, $j + 1, $current);
|
19
|
+
}
|
20
|
+
|
21
|
+
@return $list;
|
22
|
+
}
|
@@ -1,21 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}
|
1
|
+
/// Quick sort
|
2
|
+
/// @access private
|
3
|
+
/// @author Sam Richards
|
4
|
+
/// @param {List} $list - list to sort
|
5
|
+
/// @param {List} $order ($default-order) - order to use for sorting
|
6
|
+
/// @return {List}
|
7
|
+
/// @require {function} _str-compare
|
8
|
+
@function quick-sort($list, $order: $default-order) {
|
9
|
+
$less: ();
|
10
|
+
$equal: ();
|
11
|
+
$large: ();
|
12
|
+
|
13
|
+
@if length($list) > 1 {
|
14
|
+
$seed: nth($list, ceil(length($list) / 2));
|
15
|
+
|
16
|
+
@each $item in $list {
|
17
|
+
@if $item == $seed {
|
18
|
+
$equal: append($equal, $item, list-separator($list));
|
19
|
+
} @else if _str-compare($item, $seed, $order) {
|
20
|
+
$less: append($less, $item, list-separator($list));
|
21
|
+
} @else if not _str-compare($item, $seed, $order) {
|
22
|
+
$large: append($large, $item, list-separator($list));
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
@return join(join(quick-sort($less, $order), $equal), quick-sort($large, $order));
|
27
|
+
}
|
28
|
+
|
29
|
+
@return $list;
|
30
|
+
}
|
@@ -1,14 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
$
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
/// Selection sort
|
2
|
+
/// @access private
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
/// @param {List} $list - list to sort
|
5
|
+
/// @param {List} $order ($default-order) - order to use for sorting
|
6
|
+
/// @return {List}
|
7
|
+
/// @require {function} _str-compare
|
8
|
+
/// @require {function} _swap
|
9
|
+
@function selection-sort($list, $order: $default-order) {
|
10
|
+
@for $i from 1 through length($list) {
|
11
|
+
$idx: $i;
|
12
|
+
$min: nth($list, $i);
|
13
|
+
|
14
|
+
@for $j from $i + 1 through length($list) {
|
15
|
+
@if not _str-compare($min, nth($list, $j), $order) {
|
16
|
+
$min: nth($list, $j);
|
17
|
+
$idx: $j;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
$list: _swap($list, $i, $idx);
|
22
|
+
}
|
23
|
+
|
24
|
+
@return $list;
|
25
|
+
}
|
@@ -1,18 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
/// Shell sort
|
2
|
+
/// @access private
|
3
|
+
/// @author Hugo Giraudel
|
4
|
+
/// @param {List} $list - list to sort
|
5
|
+
/// @param {List} $order ($default-order) - order to use for sorting
|
6
|
+
/// @return {List}
|
7
|
+
/// @require {function} _str-compare
|
8
|
+
@function shell-sort($list, $order: $default-order) {
|
9
|
+
$gaps: 701, 301, 132, 57, 23, 10, 4, 1;
|
10
|
+
|
11
|
+
@for $k from 1 through length($gaps) {
|
12
|
+
$gap: nth($gaps, $k);
|
13
|
+
$i: $gap;
|
14
|
+
|
15
|
+
@while $i <= length($list) {
|
16
|
+
$current: nth($list, $i);
|
17
|
+
$j: $i;
|
18
|
+
|
19
|
+
@while $j >= $gap and $j - $gap > 0 and not _str-compare(nth($list, $j - $gap), $current, $order) {
|
20
|
+
$list: set-nth($list, $j, nth($list, $j - $gap));
|
21
|
+
$j: $j - $gap;
|
22
|
+
}
|
23
|
+
|
24
|
+
$list: set-nth($list, $j, $current);
|
25
|
+
$i: $i + $gap;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
@return $list;
|
30
|
+
}
|
@@ -1,12 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
@function sort
|
11
|
-
|
12
|
-
}
|
1
|
+
/// Sort function delaying to an algorithm-specific function depending on `$algorithm`
|
2
|
+
/// @access public
|
3
|
+
/// @param {List} $list - list to sort
|
4
|
+
/// @param {List} $order ($default-order) - order to deal with
|
5
|
+
/// @param {String} $algorithm ("quick") - algorithm to use
|
6
|
+
/// @return {List} - Sorted list
|
7
|
+
/// @require {function} bubble-sort
|
8
|
+
/// @require {function} comb-sort
|
9
|
+
/// @require {function} insertion-sort
|
10
|
+
/// @require {function} quick-sort
|
11
|
+
/// @require {function} selection-sort
|
12
|
+
/// @require {function} shell-sort
|
13
|
+
@function sort($list, $order: $default-order, $algorithm: "quick") {
|
14
|
+
@return call("#{$algorithm}-sort", $list, $order);
|
15
|
+
}
|
@@ -1,22 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
$a: to-lower-case($a + unquote(""));
|
13
|
-
$b: to-lower-case($b + unquote(""));
|
14
|
-
|
15
|
-
|
16
|
-
$char-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
1
|
+
/// Compares two string to determine which comes first
|
2
|
+
/// @access private
|
3
|
+
/// @param {String} $a - first string
|
4
|
+
/// @parem {String} $b - second string
|
5
|
+
/// @param {List} $order - order to deal with
|
6
|
+
/// @return {Bool}
|
7
|
+
@function _str-compare($a, $b, $order) {
|
8
|
+
@if type-of($a) == "number" and type-of($b) == "number" {
|
9
|
+
@return $a < $b;
|
10
|
+
}
|
11
|
+
|
12
|
+
$a: to-lower-case($a + unquote(""));
|
13
|
+
$b: to-lower-case($b + unquote(""));
|
14
|
+
|
15
|
+
@for $i from 1 through min(str-length($a), str-length($b)) {
|
16
|
+
$char-a: str-slice($a, $i, $i);
|
17
|
+
$char-b: str-slice($b, $i, $i);
|
18
|
+
|
19
|
+
@if $char-a and $char-b and index($order, $char-a) != index($order, $char-b) {
|
20
|
+
@return index($order, $char-a) < index($order, $char-b);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
@return str-length($a) < str-length($b);
|
25
|
+
}
|
@@ -1,16 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
$tmp: nth($list, $a);
|
13
|
-
$list: set-nth($list, $a, nth($list, $b));
|
14
|
-
$list: set-nth($list, $b, $tmp);
|
15
|
-
@return $list;
|
16
|
-
}
|
1
|
+
/// Swaps values at indexes `$a` and `$b` from `$list`
|
2
|
+
/// @access private
|
3
|
+
/// @param {List} $list - list to update
|
4
|
+
/// @param {Number} $a - index of first element
|
5
|
+
/// @param {Number} $b - index of second element
|
6
|
+
/// @return {List}
|
7
|
+
@function _swap($list, $a, $b) {
|
8
|
+
@if abs($a) > length($list) or abs($b) > length($list) {
|
9
|
+
@return $list;
|
10
|
+
}
|
11
|
+
|
12
|
+
$tmp: nth($list, $a);
|
13
|
+
$list: set-nth($list, $a, nth($list, $b));
|
14
|
+
$list: set-nth($list, $b, $tmp);
|
15
|
+
@return $list;
|
16
|
+
}
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
/// Default order used to determine which string comes first
|
2
|
+
/// @type List
|
3
|
+
$default-order:
|
4
|
+
"!" "#" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "." "/" "[" "\\" "]" "^" "_" "{" "|" "}" "~"
|
5
|
+
"0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
|
6
|
+
"a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" !default;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: SassySort
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Sass sorting function
|
15
15
|
email:
|
@@ -21,17 +21,17 @@ files:
|
|
21
21
|
- README.md
|
22
22
|
- CHANGELOG.md
|
23
23
|
- lib/SassySort.rb
|
24
|
-
- stylesheets/algorithms/_bubble-sort.scss
|
25
24
|
- stylesheets/algorithms/_comb-sort.scss
|
26
25
|
- stylesheets/algorithms/_insertion-sort.scss
|
27
|
-
- stylesheets/algorithms/_quick-sort.scss
|
28
26
|
- stylesheets/algorithms/_selection-sort.scss
|
27
|
+
- stylesheets/algorithms/_quick-sort.scss
|
29
28
|
- stylesheets/algorithms/_shell-sort.scss
|
29
|
+
- stylesheets/algorithms/_bubble-sort.scss
|
30
|
+
- stylesheets/_SassySort.scss
|
31
|
+
- stylesheets/settings/_order.scss
|
30
32
|
- stylesheets/helpers/_sort.scss
|
31
|
-
- stylesheets/helpers/_str-compare.scss
|
32
33
|
- stylesheets/helpers/_swap.scss
|
33
|
-
- stylesheets/
|
34
|
-
- stylesheets/_SassySort.scss
|
34
|
+
- stylesheets/helpers/_str-compare.scss
|
35
35
|
homepage: https://github.com/HugoGiraudel/SassySort/
|
36
36
|
licenses: []
|
37
37
|
post_install_message:
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
version: 1.3.6
|
53
53
|
requirements: []
|
54
54
|
rubyforge_project: SassySort
|
55
|
-
rubygems_version: 1.8.
|
55
|
+
rubygems_version: 1.8.23
|
56
56
|
signing_key:
|
57
57
|
specification_version: 3
|
58
58
|
summary: A collection of famous sorting algorithms implemented in Sass for Sass.
|