Java sort String array of file names by their extension

前端 未结 8 819
后悔当初
后悔当初 2021-01-13 02:29

I have an array of filenames and need to sort that array by the extensions of the filename. Is there an easy way to do this?

8条回答
  •  独厮守ぢ
    2021-01-13 02:54

    If I remember correctly, the Arrays.sort(...) takes a Comparator<> that it will use to do the sorting. You can provide an implementation of it that looks at the extension part of the string.

提交回复
热议问题