Write code to sort String Asc
//package com.book2s; public class Main { public static void main(String[] argv) { String segidxs = "book2s.com"; System.out.println(sortStringAsc(segidxs)); }/* w w w. ja v a 2 s . co m*/ public static String sortStringAsc(String segidxs) { if (isNull(segidxs)) return ""; char[] items = segidxs.toCharArray(); for (int i = 0; i < items.length; i++) { for (int j = i + 1; j < items.length; j++) { if (items[j] < items[i]) { char b = items[i]; items[i] = items[j]; items[j] = b; } } } return String.valueOf(items); } private static boolean isNull(String value) { return (value == null || value.trim().length() == 0); } }