I'd like to sort a file based on the results of a regex expression. For example, if I have the following property declarations in Obj-C
@property (nonatomic, strong) id <AlbumArtDelegate, UITextFieldDelegate> *albumArtView; // 1 @property (nonatomic, strong, readonly) UIImageView *profileView; // 2 @property (nonatomic, strong, readwrite) UIButton *postFB; // 3 @property (nonatomic, assign) UIButton *saveButton; // 4
By default they will sort in order [4, 1, 2, 3], but I would like to sort them in order of the actual property names, [1, 3, 2, 4]. I can write a regular expression to tease out just the property name, is it possible for me to sort by the results of that expression?
Is there any built-in Unix tool that will do this for me? I'm working in Xcode, so VIM/emacs solutions won't help.
Also, the reason I'd like to do this using a regex is so that I can expand my sorting algorithm to work in other situations. Use it to sort method declarations, import statements, etc.