diff --git a/node_gallery_api.admin.inc b/node_gallery_api.admin.inc
index 9aa5422..cf19cef 100644
--- a/node_gallery_api.admin.inc
+++ b/node_gallery_api.admin.inc
@@ -530,6 +530,13 @@ function node_gallery_api_settings_form($form, &$form_state) {
     '#default_value' => variable_get('node_gallery_api_activate_image_downloading_permission', FALSE),
     '#description' => t('When checked, administrators can allow users to download images, according to their role.'),
   );
+  $form['node_gallery_api_misc']['node_gallery_api_activate_chronological_sorting_button'] = array(
+    '#type' => 'checkbox',                    
+    '#weight' => 2,                           
+    '#title' => t('Activate the chronological order sorting feature in Sort Items tab?'),
+    '#default_value' => variable_get('node_gallery_api_activate_chronological_sorting_button', FALSE),
+    '#description' => t('When checked, you get an additional button in Sort Items tab, allowing to set shown images in chronological order, from JPEG exif embeded data.'),
+  );     
 
   // TODO: Recreate wizard interface.
   // $form['#submit'] = array('node_gallery_api_settings_menu_rebuild');
diff --git a/node_gallery_api.install b/node_gallery_api.install
index a74c1cd..3f33768 100644
--- a/node_gallery_api.install
+++ b/node_gallery_api.install
@@ -163,6 +163,7 @@ function node_gallery_api_install() {
 function node_gallery_api_uninstall() {
   variable_del('node_gallery_api_keyboard_shortcuts');
   variable_del('node_gallery_api_activate_image_downloading_permission');
+  variable_del('node_gallery_api_activate_chronological_sorting_button');
   variable_del('node_gallery_api_plupload_integration');
   variable_del('node_gallery_api_plupload_manage_images_integration');
   variable_del('node_gallery_api_plupload_manage_images_limit');
diff --git a/node_gallery_api.pages.inc b/node_gallery_api.pages.inc
index 8e0c4e3..4926463 100644
--- a/node_gallery_api.pages.inc
+++ b/node_gallery_api.pages.inc
@@ -92,10 +92,85 @@ function node_gallery_api_sort_items_form($form, $form_state, $gallery, $no_jque
     '#value' => t('Restore default sorting'),
     '#submit' => array('node_gallery_api_sort_items_form_remove_weights_submit'),
   );
+  if (variable_get('node_gallery_api_activate_chronological_sorting_button')) {
+    $form['chronological_sort'] = array(      
+      '#type' => 'submit',                    
+      '#value' => t('Set chronological order'),
+      '#submit' => array('node_gallery_api_sort_items_form_set_chronological_sorting'),
+    );
+  }
   return $form;
 }
 
 /**
+ * Submit function to set image weights reflecting chronological order of their making
+ */
+function node_gallery_api_sort_items_form_set_chronological_sorting($form, &$form_state) {
+  $images = array();
+  $ngid = $form_state['values']['ngid'];
+  $gallery = node_load ($ngid);
+  $files = node_gallery_api_get_items ($gallery, FALSE, FALSE);
+  $no_exif_count = 0;
+  $orig_datetime = '';
+  $exif = null;
+
+  // Get exif creation DateTime
+  foreach ($files as $file) {
+    $exif = exif_read_data (drupal_realpath ($file->node_gallery['item_file']['uri']));
+    if (isset ($exif)) {
+      if (isset($exif['DateTimeOriginal'])) {
+        $file->original_DateTime = new DateTime ($exif['DateTime']);
+      } /* It may be more valid exif keys here */
+    }
+    if (!isset ($file->original_DateTime)) {
+      if (user_access('access site reports')) {
+        drupal_set_message (t("Unable to find creation date in exif data for: ").$file->title);
+      }
+      $no_exif_count++;
+      $file->original_DateTime = $file->created;
+    }
+  }
+
+  if ($no_exif_count) {
+    drupal_set_message (t("Unable to find creation date in exif data for: ").$no_exif_count.t("media(s)"));
+
+    if ($no_exif_count == count($files)) {
+      drupal_set_message(t("The order of the images was left unchanged."));
+      return;
+    }
+  }
+
+  function chronological_date_sort ($oa, $ob) {
+    $a = $oa->original_DateTime;
+    $b = $ob->original_DateTime;
+    if ($a == $b) return 0;
+    return $a < $b ? -1 : 1;
+  }
+
+  usort ($files, 'chronological_date_sort');
+
+  $i = 0;
+  foreach ($files as $file) {
+    $images[] = array(
+      'nid' => $file->nid,
+      'ngid' => $ngid,
+      'weight' => $i,
+    );
+    $i++;
+  }
+  $batch = array(
+    'title' => t('Updating image order'),
+    'operations' => array(array('node_gallery_api_batch_sorting_callback', array($images))),
+    'finished' => 'node_gallery_api_batch_sorting_finished',
+    'file' => drupal_get_path('module', 'node_gallery_api') . '/node_gallery_api.inc',
+    'init_message' => t('New image positions are being calculated.'),
+    'progress_message' => t('Processing image sorting.'),
+    'error_message' => t('Image sorting has encountered an error.'),
+  );
+  batch_set($batch);
+}
+
+/**
  * Submit function to reset all image weights in a gallery to 0,
  * effectively removing any custom sort.
  */
