Giúp hướng dẫn xây dựng hoàn thiện hàm sắp xếp (dựa vào hàm xóa)

Delete Function:

private void xoaNhanVien() {
    if (listNVs.size() < 1) {
        System.out.println("Danh sach rong!");
        return;
    }
    boolean tf;
    int index = this.indexByName();
    if (index >= 0 && index < listNVs.size()) {
        do {
            System.out.print("Ban co muon xoa khong (y/n) >");
            String yn = sc.nextLine();
            if (yn.trim().equalsIgnoreCase("y"))
                if (this.xoa(index)) {
                    System.out.println("Xoa thanh cong!");
                    tf = true;
                } else {
                    System.out.println("Xoa that bai!");
                    tf = true;
                }
            else if (yn.trim().equalsIgnoreCase("n"))
                tf = true;
            else
                tf = false;
        } while (tf != true);
    } else
        System.out.println("Khong tim thay nhan vien nay!!");
}

Sort Function

private void sapXepNhanVien() {
    if (listNVs.size() < 1) {
        System.out.println("Danh sach rong!");
        return;
    }
    int index = this.indexByName();
    for (int i = 0; i < listNVs.size() - 1; i++) {
        for (int j = i + 1; j < listNVs.size(); j++) {
            if (listNVs.get(i).getTen().compareTo(listNVs.get(j).getTen()) > 0) {
                Collections.swap(listNVs, i, j);
            }
        }
    } 
    listNVs.forEach(() -> {
        System.out.println(.toString());
    });
}

Duplicate topic: Chuyển chức năng xóa sang chức năng sắp xếp tăng dần, giảm dần với cấu trúc
Cậu nên chỉ tạo 1 topic cho 1 vấn đề thôi @Luong_Dat_Entertainm.
Ngoài ra, cậu cũng nên đề cập rõ vấn đề của cậu. Khi đó mọi người mới giúp được.

Hi vọng cậu có trải nghiệm tốt khi sử dụng diễn đàn.

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?