@ Action ( name = "List Sort" , outputs = { @ Output ( RESULT_TEXT ) , @ Output ( RESPONSE ) , @ Output ( RETURN_RESULT ) , @ Output ( RETURN_CODE ) } , responses = { @ Response ( text = SUCCESS , field = RETURN_CODE , value = RETURN_CODE_SUCCESS , matchType = MatchType . COMPARE_EQUAL ) , @ Response ( text = FAILURE , field = RETURN_CODE , value = RETURN_CODE_FAILURE , matchType = MatchType . COMPARE_EQUAL , isOnFail = true , isDefault = true ) } ) public Map < String , String > sortList ( @ Param ( value = LIST , required = true ) String list , @ Param ( value = DELIMITER , required = true ) String delimiter , @ Param ( value = REVERSE ) String reverse ) { Map < String , String > result = new HashMap <> ( ) ; try { String sortedList = sort ( list , Boolean . parseBoolean ( reverse ) , delimiter ) ; result . put ( RESULT_TEXT , sortedList ) ; result . put ( RESPONSE , SUCCESS ) ; result . put ( RETURN_RESULT , sortedList ) ; result . put ( RETURN_CODE , RETURN_CODE_SUCCESS ) ; } catch ( Exception e ) { result . put ( RESULT_TEXT , e . getMessage ( ) ) ; result . put ( RESPONSE , FAILURE ) ; result . put ( RETURN_RESULT , e . getMessage ( ) ) ; result . put ( RETURN_CODE , RETURN_CODE_FAILURE ) ; } return result ; }
This method sorts a list of strings . If the list contains only numerical strings it is sorted in numerical order . Otherwise it is sorted alphabetically .