I've been trying to sort the items in the shopping cart box and in page in descending order, means the the last add items top of the box followed by the ones added before them...I'm able to achieve this when the customer is logged in by making the following changes in the classes/shopping_cart.php

under this function:
function add_cart($products_id, $qty = '1', $attributes = '', $notify = true)

at the end of this function i added the following :

$this->reset(false);
$products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' order by customers_basket_id DESC ");
while ($products = tep_db_fetch_array($products_query)) {

$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);
// attributes
$attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");
while ($attributes = tep_db_fetch_array($attributes_query)) {
$this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
}
}
----

but my problem is this works well when a customer is signed in... but if he isnt, he is not able to add anything into the cart...
i suspect this codeis to be blamed for:
$this->reset(false);

---- so i checked the reset function in the same page

function reset($reset_database = false) {
global $customer_id;
$this->contents = array();
$this->total = 0;
$this->weight = 0;
//LINE ADDED: MOD - indvship
$this->shiptotal = 0;
$this->content_type = false;

if (tep_session_is_registered('customer_id') && ($reset_database == true)) {

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
}

unset($this->cartID);
if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');
}
----------

i dont know how to fix this, anyhelp will be appreciated and plus i feel this a cool feature, because like my site having more than 4000 items and if there are more than 10 items in the cart, its easy for customer to see what they added last.... thanks