package seedu.task.logic.commands;

import java.util.logging.Logger;

import seedu.task.commons.core.LogsCenter;
import seedu.task.commons.util.ConfigUtil;

/**
 * @@author A0147944U
 * Lists all tasks in the task manager to the user.
 */
public class SortCommand extends Command {
    
    private static final Logger logger = LogsCenter.getLogger(ConfigUtil.class);

    public static final String COMMAND_WORD = "sort";
    
    public static final String MESSAGE_USAGE = COMMAND_WORD + ": asdasd"
            + "the specified keywords (case-sensitive) and displays them as a list with index numbers.\n"
            + "Parameters: KEYWORD\n"
            + "Example: " + COMMAND_WORD + " deadline";

    public static final String MESSAGE_SUCCESS = "Listed all tasks";
    
    private final String keyword;
    
    public SortCommand(String keyword) {
        logger.warning("Listing by: " + keyword);
        if (keyword.startsWith("d")) { //deadline
            this.keyword = "Deadline";
        } else if (keyword.startsWith("s")) { //start time
            this.keyword = "Start Time";
        } else if (keyword.startsWith("e")) { //end time
            this.keyword = "End Time";
        } else if (keyword.startsWith("c")) { //done status
            this.keyword = "Completed";
        } else if (keyword.startsWith("n")) { //name
            this.keyword = "Name";
        } else { //default sorting
            this.keyword = "Default";
        }
    }

    @Override
    public CommandResult execute(boolean isUndo) {
            model.sortFilteredTaskList(keyword);
            logger.warning("Listing by: " + keyword);
        return new CommandResult(MESSAGE_SUCCESS);
    }

    @Override
    public CommandResult execute(int index) {
        // TODO Auto-generated method stub
        return null;
    }
}

@@ -33,129 +33,8 @@
 s;%0A%0A
-import java.util.logging.Logger;%0A%0Aimport seedu.task.commons.core.LogsCenter;%0Aimport seedu.task.commons.util.ConfigUtil;%0A%0A
 /**%0A
@@ -157,94 +157,8 @@
 nd %7B
-%0A    %0A    private static final Logger logger = LogsCenter.getLogger(ConfigUtil.class);
 %0A%0A  
@@ -283,117 +283,138 @@
  %22: 
-asdasd%22%0A            + %22the specified keywords (case-sensitive) and displays them as a list with index numbers
+Sorts tasks according to specified parameters.%22%0A            + %22If parameter is not given, tasks will be sorted by a default preset
 .%5Cn%22
@@ -445,15 +445,17 @@
 rs: 
-KEYWORD
+PARAMETER
 %5Cn%22%0A
@@ -577,16 +577,33 @@
 ll tasks
+ with order: %251$s
 %22;%0A    %0A
@@ -649,84 +649,126 @@
     
-public SortCommand(String keyword) %7B%0A        logger.warning(%22Listing by: %22 +
+/**%0A     * Parse the keyword given by user based on first character of the input%0A     */%0A    public SortCommand(String
  key
@@ -764,33 +764,34 @@
 (String keyword)
-;
+ %7B
 %0A        if (key
@@ -1330,32 +1330,115 @@
        %7D%0A    %7D%0A%0A
+    /**%0A     * Executes 'sortFilteredTaskList' and returns success message%0A     */%0A
     @Override%0A  
@@ -1539,62 +1539,8 @@
 d);%0A
-            logger.warning(%22Listing by: %22 + keyword);%0A
     
@@ -1568,16 +1568,30 @@
 dResult(
+String.format(
 MESSAGE_
@@ -1597,16 +1597,26 @@
 _SUCCESS
+, keyword)
 );%0A    %7D

Improve SortCommand