How to sort number in alphanumeric

前端 未结 5 411
失恋的感觉
失恋的感觉 2021-01-03 01:16

Input:

SHC 111U,SHB 22x,, SHA 5555G

Needed output:

SHB 22X, SHC 111U, SHA 5555G

I

5条回答
  •  情话喂你
    2021-01-03 01:33

    Use a Sort method that accepts an IComparer object and pass it your collection of vehicle numbers. You will need to define a custom class that implements IComparer. In the Compare method of that class you can write code to compare the two vehicle numbers. You should probably use a regex for extracting the numerical part of the vehicle number.

提交回复
热议问题