--[[----------------------------------------------------------------------------

WFCatSortByAssetId.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2015 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remains the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and are protected by all applicable
intellectual property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

----------------------------------------------------------------------------]]--

--==============================================================================

local WFCatSortByAssetId = {}

--------------------------------------------------------------------------------
function WFCatSortByAssetId.executeSort( wfCatalog, assetIds, order )
	
	-- no need for an SQL query here, just sort the asset ids, in ascending or descending order
	if order == "ASC" then
		table.sort( assetIds )
	else
		table.sort( assetIds, function(a,b) return a > b end  )
	end

	-- return table of tables to satisfy callers (Rx)
	local temp = {}
	for i, assetId in ipairs (assetIds) do
		temp[i] = {assetId, 0}
	end
	
	return require"Rx".Observable.just( temp )
end
	


--==============================================================================

return WFCatSortByAssetId
