changed CHANGELOG.md
 
@@ -4,6 +4,12 @@
4
4
they can and will change without that change being reflected in Styler's semantic version.
5
5
## main
6
6
7
+ ## 1.3.2
8
+
9
+ ### Improvements
10
+
11
+ - `# styler:sort` can be used to sort values of key-value pairs. eg, sort the value of a single key in a map (Closes #208, h/t @ypconstante)
12
+
7
13
## 1.3.1
8
14
9
15
### Improvements
changed hex_metadata.config
 
@@ -1,6 +1,6 @@
1
1
{<<"links">>,[{<<"GitHub">>,<<"https://github.com/adobe/elixir-styler">>}]}.
2
2
{<<"name">>,<<"styler">>}.
3
- {<<"version">>,<<"1.3.1">>}.
3
+ {<<"version">>,<<"1.3.2">>}.
4
4
{<<"description">>,
5
5
<<"A code-style enforcer that will just FIFY instead of complaining">>}.
6
6
{<<"elixir">>,<<"~> 1.15">>}.
changed lib/style.ex
 
@@ -240,6 +240,7 @@ defmodule Styler.Style do
240
240
def meta({_, meta, _}), do: meta
241
241
# kwl tuple ala a: :b
242
242
def meta({{_, meta, _}, _}), do: meta
243
+ def meta(_), do: nil
243
244
244
245
@doc """
245
246
Returns all comments "for" a node, including on the line before it.
changed lib/style/comment_directives.ex
 
@@ -27,9 +27,9 @@ defmodule Styler.Style.CommentDirectives do
27
27
|> Enum.map(& &1.line)
28
28
|> Enum.reduce({zipper, ctx.comments}, fn line, {zipper, comments} ->
29
29
found =
30
- Zipper.find(zipper, fn
31
- {_, meta, _} -> Keyword.get(meta, :line, -1) >= line
32
- _ -> false
30
+ Zipper.find(zipper, fn node ->
31
+ node_line = Style.meta(node)[:line] || -1
32
+ node_line >= line
33
33
end)
34
34
35
35
if found do
 
@@ -102,5 +102,10 @@ defmodule Styler.Style.CommentDirectives do
102
102
{{:@, m, [{a, am, [assignment]}]}, comments}
103
103
end
104
104
105
+ defp sort({key, value}, comments) do
106
+ {value, comments} = sort(value, comments)
107
+ {{key, value}, comments}
108
+ end
109
+
105
110
defp sort(x, comments), do: {x, comments}
106
111
end
changed mix.exs
 
@@ -12,7 +12,7 @@ defmodule Styler.MixProject do
12
12
use Mix.Project
13
13
14
14
# Don't forget to bump the README when doing non-patch version changes
15
- @version "1.3.1"
15
+ @version "1.3.2"
16
16
@url "https://github.com/adobe/elixir-styler"
17
17
18
18
def project do