Automator: replace text input not working What I want to do

I want to create a simple Automator service that:


Takes text as input from any application,
Does some logic on given input
Replaces the selected input text with the calculated output


The problem

The return value in the JS script does not replace the selected input text. I have no clue why. Does anyone have experience with this?

I am running macOS Sierra 10.12, using Automator 2.7
The problem was related to the macOS version. After updating to 10.12.1 the text is now being correctly replaced!



Edit: for those interested in the alphabetic sorting, simply add a Run Shell Script block and fill in sort -f, like so: