package ru.matevosyan;

import java.util.*;

public class UserSort {


    public Set<User> sort(List<User> userList) {

        Iterator<User> userIterator = userList.listIterator();
        TreeSet<User> userTreeSet = new TreeSet<>();

        while (userIterator.hasNext()) {
            User user = userIterator.next();
            userTreeSet.add(user);
        }
        return userTreeSet;
    }

    public List<User> sortHash (List<User> users) {
        Collections.sort(users, new Comparator<User>() {
            @Override
        public int compare(User user1, User user2) {
                Integer user1Hash = user1.hashCode();
                Integer user2Hash = user2.hashCode();

                return user1Hash.compareTo(user2Hash);
            }
    });
        return users;
    }

    public List<User> sortLength (List<User> users) {
        Collections.sort(users, new Comparator<User>() {
            @Override
            public int compare(User o1, User o2) {
                Integer user1Length = o1.getName().length();
                Integer user2Length = o2.getName().length();

                return user1Length.compareTo(user2Length);
            }
        });
        return users;
    }

}

@@ -42,32 +42,340 @@
 *;%0A%0A
-public class UserSort %7B%0A
+/**%0A * UserSort was created to sort list ans set.%0A * Created on 28.04.2017.%0A * @author Matevosyan Vardan%0A * @version 1.0%0A */%0A%0Apublic class UserSort %7B%0A%0A    /**%0A     * sort method sorted convert list to treeSet and sort treeSet with comparable class.%0A     * @param userList list of users.%0A     * @return sorted treeSet by age.%0A     */
 %0A%0A  
@@ -697,32 +697,184 @@
 TreeSet;%0A    %7D%0A%0A
+    /**%0A     * sortHash use to sort list with comparator by hash code.%0A     * @param users list od users.%0A     * @return sorted list of users.%0A     */%0A%0A
     public List%3C
@@ -1252,24 +1252,180 @@
 ers;%0A    %7D%0A%0A
+    /**%0A     * sortLength use to sort list with comparator by length name.%0A     * @param users list od users.%0A     * @return sorted list of users.%0A     */%0A%0A
     public L

add javadoc