1. 遍历目标字符串,将字符逐一添加到list集合中去
  2. 设定list集合的排序规则
  3. 输出list集合

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class Main{
    public static void sortASCII(String s){
        List<Character> list = new ArrayList<>();// 将字符串s按照空格分隔然后写入list集合
        // 添加到list集合
        for(int i = 0; i < s.length();i++){
            list.add(s.charAt(i));
        }
        // 排序
        list.sort(new Comparator<Character>() {
            @Override
            public int compare(Character o1, Character o2) {
                return (int)o1 - (int)o2;// 根据ASCII值升序
            }
        });
        // 输出解雇
        for(int i = 0 ; i < list.size();i++){
            System.out.print(list.get(i));
        }
        System.out.println();
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String target = new String(sc.nextLine());
            sortASCII(target);
        }
    }
    }