From f095ec4bb00aa66e9af7bfcdde72fadea21dfa12 Mon Sep 17 00:00:00 2001
From: andrew morton <drewish@katherinehouse.com>
Date: Thu, 19 Jul 2012 16:44:14 -0400
Subject: [PATCH] Issue #1440340 by drewish:
 WebformSubmissionsController::load() returns entities in
 incorrect order.

---
 webform_entity.module |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/webform_entity.module b/webform_entity.module
index c44501a..eed55da 100644
--- a/webform_entity.module
+++ b/webform_entity.module
@@ -662,7 +662,12 @@ class WebformSubmissionsController extends DrupalDefaultEntityController {
       }
       // TODO: Maybe figure out a way to prevent what is essentially a double load.
       // We hook into the webform load op
-      $submissions = webform_get_submissions($sids);
+      $fetched = webform_get_submissions($sids);
+      // Re-key the submissions so they're in the order requested.
+      $submissions = array();
+      foreach ($ids as $id) {
+        $submissions[$id] = isset($fetched[$id]) ? $fetched[$id] : NULL;
+      }
     }
     else {
       $submissions = array();
-- 
1.7.10.4

