function addSortingMetadata(req, collectionMetadata) {
	var params = extractUrlParams(req.originalUrl);
	var sortingParam = params[starkQueryParam.SORT] ? decodeURIComponent(params[starkQueryParam.SORT]) : undefined;

	const sortingRegex = /(\w+)\+(ASC|DESC)/g; // perform a global search to match all the sort items

	if (sortingParam && sortingParam.match(sortingRegex)) {
		var sortedBy = [];

		const sortingParams = sortingParam.match(sortingRegex);

		sortingParams.forEach(function (sortingParam) {
			sortedBy.push({
				field: sortingParam.split("+")[0],
				order: sortingParam.split("+")[1]
			});
		});

		collectionMetadata[starkMetadata.SORTED_BY] = sortedBy;
	}
}
/**
 * Add "sortedBy" object to metadata for Collection responses (if "sort" is defined in the query parameters)
 * @param req {*} The current request
 * @param collectionMetadata {object} Metadata object constructed by the Stark middleware (only for Collection responses)
 */
Add "sortedBy" object to metadata for Collection responses (if "sort" is defined in the query parameters)
@param req {*} The current request
@param collectionMetadata {object} Metadata object constructed by the Stark middleware (only for Collection responses)
Add " sortedBy " object to metadata for Collection responses ( if " sort " is defined in the query parameters ) @param req { * } The current request @param collectionMetadata { object } Metadata object constructed by the Stark middleware ( only for Collection responses )
function addSortingMetadata(req, collectionMetadata) {
	var params = extractUrlParams(req.originalUrl);
	var sortingParam = params[starkQueryParam.SORT] ? decodeURIComponent(params[starkQueryParam.SORT]) : undefined;
	const sortingRegex = /(\w+)\+(ASC|DESC)/g; 
	if (sortingParam && sortingParam.match(sortingRegex)) {
		var sortedBy = [];
		const sortingParams = sortingParam.match(sortingRegex);
		sortingParams.forEach(function (sortingParam) {
			sortedBy.push({
				field: sortingParam.split("+")[0],
				order: sortingParam.split("+")[1]
			});
		});
		collectionMetadata[starkMetadata.SORTED_BY] = sortedBy;
	}
}
function addSortingMetadata ( req , collectionMetadata ) { var params = extractUrlParams ( req . originalUrl ) ; var sortingParam = params [ starkQueryParam . SORT ] ? decodeURIComponent ( params [ starkQueryParam . SORT ] ) : undefined ; const sortingRegex = / (\w+)\+(ASC|DESC) / g ; if ( sortingParam && sortingParam . match ( sortingRegex ) ) { var sortedBy = [ ] ; const sortingParams = sortingParam . match ( sortingRegex ) ; sortingParams . forEach ( function ( sortingParam ) { sortedBy . push ( { field : sortingParam . split ( "+" ) [ 0 ] , order : sortingParam . split ( "+" ) [ 1 ] } ) ; } ) ; collectionMetadata [ starkMetadata . SORTED_BY ] = sortedBy ; } }
Add "sortedBy" object to metadata for Collection responses (if "sort" is defined in the query parameters)
 @param req {*} The current request
 @param collectionMetadata {object} Metadata object constructed by the Stark middleware (only for Collection responses)
Add " sortedBy " object to metadata for Collection responses ( if " sort " is defined in the query parameters ) @param req { * } The current request @param collectionMetadata { object } Metadata object constructed by the Stark middleware ( only for Collection responses )
// perform a global search to match all the sort items