package seedu.tasklist.logic.commands;


public class SortCommand extends Command {

    public static final String COMMAND_WORD = "sort";
    private final String parameter;

    public static final String MESSAGE_USAGE = COMMAND_WORD
            + ":Sorts task according to the parameter specified. "
            + "Only 1 of the 5. "
            + "Name:n"
            + "Priority:p or StartDate: sd or EndDate:ed or Deadline:d\n"
            + "Parameters: n, p, sd, ed\n"
            + "Example: " + COMMAND_WORD + " n";
    public static final String MESSAGE_FAILURE = "Invalid sorting parameter used!" + MESSAGE_USAGE;
    public static final String MESSAGE_SUCCESS = "Task sorted according to given parameter.";

    public SortCommand(String parameter) {
        switch (parameter) {
        case "d":
            this.parameter = "Deadline";
            break;
        case "sd":
            this.parameter = "Start Date";
            break;
        case "ed":
            this.parameter = "End Date";
            break;
        case "n":
            this.parameter = "Name";
            break;
        case "p":
            this.parameter = "Priority";
            break;
        default:
            this.parameter = null;
        }
    }

    @Override
    public CommandResult execute() {

        if (parameter == null) {
            return new CommandResult(MESSAGE_FAILURE);
        }
        model.sortTaskList(parameter);
        return new CommandResult(MESSAGE_SUCCESS);
    }

}

@@ -33,16 +33,38 @@
 mands;%0A%0A
+import java.util.Set;%0A
 %0Apublic 
@@ -166,22 +166,16 @@
 private 
-final 
 String p
@@ -184,16 +184,55 @@
 ameter;%0A
+    private String order = %22default%22;%0A%0A
 %0A    pub
@@ -478,16 +478,58 @@
 adline:d
+%22%0A            + %22dsc for descending order 
 %5Cn%22%0A    
@@ -556,19 +556,27 @@
 s: n
+/
 , p
+/
 , sd
+/
 , ed
+/ dsc
 %5Cn%22%0A
@@ -814,17 +814,16 @@
 arameter
-.
 %22;%0A%0A    
@@ -833,246 +833,566 @@
 lic 
-SortCommand(String parameter) %7B%0A        switch (parameter) %7B%0A        case %22d%22:%0A            this.parameter = %22Deadline
+static final String SORT_NAME = %22n/%22;%0A    public static final String SORT_PRIORITY = %22p/%22;%0A    public static final String SORT_DEADLINE = %22d/%22;%0A    public static final String SORT_START_DATE = %22sd/%22;%0A    public static final String SORT_END_DATE = %22ed/%22;%0A    public static final String SORT_DESCENDING = %22dsc
 %22;%0A    
+%0A
     
-    break;%0A        case %22sd%22:%0A            this.parameter = %22Start Date%22;
+private Set%3CString%3E keyword; %0A%0A    public SortCommand(Set%3CString%3E args) %7B%0A        assert args != null;%0A        this.keyword = args; 
 %0A    
+%7D%0A
     
+%0A
     
-break;%0A        case %22ed%22:
+@Override%0A    public CommandResult execute() %7B  %0A        if (keyword.contains(SORT_NAME)) %7B
 %0A   
@@ -1422,15 +1422,11 @@
  = %22
-End Dat
+Nam
 e%22;%0A
@@ -1437,36 +1437,148 @@
     
-    break;%0A        case %22n%22:
+%7D else if (keyword.contains(SORT_PRIORITY)) %7B%0A            this.parameter = %22Priority%22;%0A        %7D else if (keyword.contains(SORT_DEADLINE)) %7B
 %0A   
@@ -1596,35 +1596,39 @@
 is.parameter = %22
-Nam
+Deadlin
 e%22;%0A            
@@ -1627,36 +1627,55 @@
     
-    break;%0A        case %22p%22:
+%7D else if (keyword.contains(SORT_START_DATE)) %7B
 %0A   
@@ -1697,32 +1697,34 @@
 arameter = %22
-Priority
+Start Date
 %22;%0A         
@@ -1726,35 +1726,53 @@
     
-    break;%0A        default:
+%7D else if (keyword.contains(SORT_END_DATE)) %7B
 %0A   
@@ -1797,20 +1797,26 @@
 meter = 
-null
+%22End Date%22
 ;%0A      
@@ -1823,65 +1823,99 @@
   %7D%0A
+%0A 
     
-%7D%0A%0A    @Override%0A    public CommandResult execute() %7B
+   if (keyword.contains(SORT_DESCENDING)) %7B%0A            this.order = %22dsc%22;%0A        %7D
 %0A%0A  
@@ -1924,16 +1924,21 @@
     if (
+this.
 paramete
@@ -1946,16 +1946,38 @@
  == null
+ %7C%7C keyword.size() %3E 3
 ) %7B%0A    
@@ -2064,16 +2064,21 @@
 askList(
+this.
 paramete
@@ -2078,16 +2078,28 @@
 arameter
+, this.order
 );%0A     

Update SortCommand.java to include descending order