diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java index 2bbcee2d43..44ea053b34 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java @@ -106,7 +106,9 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe List recordIds = getRecordIds(resultEntries); AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); eventRecords.setCount(eventCount); - eventRecords.setList(AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response)); + List records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response); + records.sort((Record r1, Record r2) -> Long.compare(r2.getTimestamp(), r1.getTimestamp())); + eventRecords.setList(records); return eventRecords; }