diff --git a/public/app/features/explore/utils/ResultProcessor.ts b/public/app/features/explore/utils/ResultProcessor.ts index 958c1374f1f..091495bb4d2 100644 --- a/public/app/features/explore/utils/ResultProcessor.ts +++ b/public/app/features/explore/utils/ResultProcessor.ts @@ -50,7 +50,20 @@ export class ResultProcessor { return null; } - const onlyTables = this.dataFrames.filter(frame => shouldShowInVisualisationType(frame, 'table')); + const onlyTables = this.dataFrames + .filter((frame: DataFrame) => shouldShowInVisualisationType(frame, 'table')) + .sort((frameA: DataFrame, frameB: DataFrame) => { + const frameARefId = frameA.refId!; + const frameBRefId = frameB.refId!; + + if (frameARefId > frameBRefId) { + return 1; + } + if (frameARefId < frameBRefId) { + return -1; + } + return 0; + }); if (onlyTables.length === 0) { return null;