func ParseSorting(s string) (*Sorting, error) {
	var sorting Sorting

	for _, craw := range strings.Split(s, ",") {
		v := strings.Fields(craw)

		var c SortCriteria
		switch len(v) {
		case 1:
			c.Tag, c.Order = v[0], SortCriteria_ASC
		case 2:
			if o, ok := SortCriteria_Order_value[strings.ToUpper(v[1])]; !ok {
				return nil, fmt.Errorf("invalid sort order - %q in %q", v[1], craw)
			} else {
				c.Tag, c.Order = v[0], SortCriteria_Order(o)
			}
		default:
			return nil, fmt.Errorf("invalid sort criteria: %s", craw)
		}

		sorting.Criterias = append(sorting.Criterias, &c)
	}

	return &sorting, nil
}
// ParseSorting parses raw string that represent sort criteria into a Sorting
// data structure.
// Provided string is supposed to be in accordance with the sorting collection
// operator from REST API Syntax.
// See: https://github.com/valadzko/atlas-app-toolkit#sorting
ParseSorting parses raw string that represent sort criteria into a Sorting
data structure.
Provided string is supposed to be in accordance with the sorting collection
operator from REST API Syntax.
// ParseSorting parses raw string that represent sort criteria into a Sorting // data structure . // Provided string is supposed to be in accordance with the sorting collection // operator from REST API Syntax . // See : https : // github . com / valadzko / atlas - app - toolkit#sorting
func ParseSorting(s string) (*Sorting, error) {
	var sorting Sorting
	for _, craw := range strings.Split(s, ",") {
		v := strings.Fields(craw)
		var c SortCriteria
		switch len(v) {
		case 1:
			c.Tag, c.Order = v[0], SortCriteria_ASC
		case 2:
			if o, ok := SortCriteria_Order_value[strings.ToUpper(v[1])]; !ok {
				return nil, fmt.Errorf("invalid sort order - %q in %q", v[1], craw)
			} else {
				c.Tag, c.Order = v[0], SortCriteria_Order(o)
			}
		default:
			return nil, fmt.Errorf("invalid sort criteria: %s", craw)
		}
		sorting.Criterias = append(sorting.Criterias, &c)
	}
	return &sorting, nil
}
func ParseSorting ( s string ) ( * Sorting , error ) { var sorting Sorting for _ , craw := range strings . Split ( s , " " ) { v := strings . Fields ( craw ) var c SortCriteria switch len ( v ) { case 1 : c . Tag , c . Order = v [ 0 ] , SortCriteria_ASC case 2 : if o , ok := SortCriteria_Order_value [ strings . ToUpper ( v [ 1 ] ) ] ; ! ok { return nil , fmt . Errorf ( " " , v [ 1 ] , craw ) } else { c . Tag , c . Order = v [ 0 ] , SortCriteria_Order ( o ) } default : return nil , fmt . Errorf ( " " , craw ) } sorting . Criterias = append ( sorting . Criterias , & c ) } return & sorting , nil }
ParseSorting parses raw string that represent sort criteria into a Sorting
data structure.
ParseSorting parses raw string that represent sort criteria into a Sorting data structure .