How to sort elements of array list in C#

后端 未结 9 1148
梦如初夏
梦如初夏 2021-02-14 23:42

I have an ArrayList that contains,

[0] = \"1\"
[1] = \"10\"
[2] = \"2\"
[3] = \"15\"
[4] = \"17\"
[5] = \"5\"
[6] = \"6\"
[7] = \"27\"
[8] = \"8\"
[9] = \"9\"
         


        
9条回答
  •  我寻月下人不归
    2021-02-15 00:17

    If the values are all ints then why not store them as ints? That would make sorting easier and faster.

    In what other ways are the values used? If they're only used as strings and only sorted once then it's probably sensible to leave them as they are - as strings.

    On the other hand, if they're used in maths ops then it's best to store them as ints.

提交回复
热议问题