+/**
+ * @return Returns the array sorted as required
+ * @param $aryData Array containing data to sort
+ * @param $strIndex name of column to use as an index
+ * @param $strSortBy Column to sort the array by
+ * @param $strSortType String containing either asc or desc [default to asc]
+ * @desc Naturally sorts an array using by the column $strSortBy
+ */
+define('EXPORT_MAX_INSERT', 50000);
+
+function array_natsort($aryData, $strIndex, $strSortBy, $strSortType=false)
+{
+ // if the parameters are invalid
+ if (!is_array($aryData) || !$strSortBy)
+ // return the array
+ return $aryData;
+
+ // create our temporary arrays
+ $arySort = $aryResult = array();
+
+ // loop through the array
+ foreach ($aryData as $key => $aryRow)
+ // set up the value in the array
+ $arySort[$strIndex ? $aryRow[$strIndex] : $key] = $aryRow[$strSortBy];
+
+ // apply the natural sort
+ natsort($arySort);
+
+ // if the sort type is descending
+ if ($strSortType=="desc")
+ // reverse the array
+ arsort($arySort);
+
+ // loop through the sorted and original data
+ foreach ($arySort as $arySortKey => $arySorted)
+ if($strIndex)
+ {
+ foreach ($aryData as $aryOriginal)
+ // if the key matches
+ if ($aryOriginal[$strIndex]==$arySortKey)
+ // add it to the output array
+ array_push($aryResult, $aryOriginal);
+ } else
+ $aryResult[$arySortKey] = $aryData[$arySortKey];
+ // return the return
+ return $aryResult;
+}
+
+function update_admin_password($conn, $password)
+{
+ $sql = "UPDATE ".$conn['tbpref']."users SET password=".db_escape($password) . "
+ WHERE user_id='admin'";
+ db_query($sql, "could not update user password for 'admin'");
+}
+