Extend file output plugin

Hi,

I want to customise file output plugin such that it sorts the chunks according to a field before writing them. I'm looking for extending the existing file plugin rather than duplicating its code, but facing issues in initialisation of the extended plugin.
Are there any examples to refer for extending file output plugin?