I like Textmate's "Sort Lines in Selection" feature a lot. Is there something similar for Xcode 4? If not, what would be the best way to integrate such a feature (a plugin, Applescript, ...)?
You can do this with Automator in Lion.
sort -finto the "Run Shell Script" textfield
Now you can sort lines in any textfield. Select some text and right-click or Control click and select the service you just created.