KDE SC 4.4 has a Plasma widget allowing to pate output of some commands.

Using xclip, I can get content of current clipboard. So it is possible to add a macro to sort current selected text:

 %{exec(bash -c "xclip -o | sort")}

Better, I can ask to user what command he wants to apply:

 %{exec(bash -c "xclip -o | $(kdialog --inputbox 'Command?' 'wc -c')")}

Now, I can filter text in any applications: Firefox, OpenOffice, Kmail....

Only one problem, I can yet assign a shortcut to this action.