Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to sort a list of values according to numeric, alpha numeric, aplhabetic and strings with special characters which occur in the same position
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/104599/sort-on-a-string-that-may-contain-a-number">Sort on a string that may contain a number</a><br> <a href="https://stackoverflow.com/questions/7567646/how-to-sort-a-collection-which-has-strings-integers-and-alphanumerics-in-java">how to sort a collection which has strings, integers and alphanumerics in java</a> </p> </blockquote> <p>I have some values like</p> <p><code>AB, 1, 01, 10, 9, 100, 1AB2, aa, 1.23, -0.11, 0.11, #1.21, #0.11, #9.1, A-101, A-202, A-303, A-100, A-001, A-2, A-1, 3.@1, 3.@10, 3.@100, 3.@2, 0.01%, 3.12%, -0.1%, $12, $1.23</code> </p> <p>and so on. So, I mean to say that I have some collection of values which include alpha, alphanumeric, numeric and some strings which have some special characters in the<code>(#,$,%,-)</code>.</p> <p>Now, when i try to sort them using collections.sort() function, it is doing string sorting and the numbers are not getting sorted in order(output coming as <code>01,1,10,100,9</code> whereas i require <code>01,1,9,10,100</code>). I got the answer for this numeric sorting. But, I require all the strings which have special characters in them <code>(#,$,%,-)</code> to be together after the sort(the position at which the special character occurs in the string will always be the same like #1.21, #0.11, etc explains the same).</p> <p>I am facing a problem with this occurrence pattern since its working fine with '#' symbol(which occurs at the start of string) but strings which have '%' at the end of the string are not grouping together. I really dont care where these strings occur in the sorted list(they can come at the start or end or in the middle but all strings with a particular special character should be grouped together). I think we should use regular expressions for doing this. Can anyone explain me how to achieve this with the help of some code?? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload