function applySort(oXhr, aResultSet) {
		var sFieldName,
			sDirection,
			aSortedUsers = [].concat(aResultSet), // work with a copy
			aMatches = oXhr.url.match(/\$orderby=(\w*)(?:%20(\w*))?/);

		if (!Array.isArray(aMatches) || aMatches.length < 2) {
			return aSortedUsers;
		}
		sFieldName = aMatches[1];
		sDirection = aMatches[2] || "asc";

		if (sFieldName !== "LastName") {
			throw new Error("Filters on field " + sFieldName + " are not supported.");
		}

		aSortedUsers.sort(function (a, b) {
			var nameA = a.LastName.toUpperCase(),
				nameB = b.LastName.toUpperCase(),
				bAsc = sDirection === "asc";

			if (nameA < nameB) {
				return bAsc ? -1 : 1;
			}
			if (nameA > nameB) {
				return bAsc ? 1 : -1;
			}
			return 0;
		});

		return aSortedUsers;
	}
Sorts a given result set by applying the OData URL parameter 'orderby'.
Does NOT change the given result set but returns a new array.
@param {Object} oXhr - the Sinon fake XMLHttpRequest
@param {Array} aResultSet - the result set to be sorted.
@returns {Array} the sorted result set.