Sort Posts by Multiple Meta Values [duplicate]

Since I couldn’t find the way to grab the custom post’s title and add it to the sorting/ordering by meta_key, I edited my custom post type to include a hidden field that grabs the title of the post and sets it as a custom meta value when the user adds a new custom post. So, in my custom post type plugin, I have:

<input type="hidden" name="buy_location_name" value="<?php echo get_the_title($buy_location->ID); ?>" />

if ( isset( $_POST['buy_location_name'] ) && $_POST['buy_location_name'] != '' ) 
 { update_post_meta( $buy_location_id, 'location_name', get_the_title($buy_location_id) ); }

And then on the frontend page that posts the results sorted by State, City and finally Store name, I use the example code found in this URL: http://wordpress.mcdspot.com/2012/10/24/sort-posts-on-multiple-custom-fields/

My code starts like so…

$meta_keys = array('store_state','store_city','location_name');
$args = array(
    'post_type' => 'buy_locations',
    'meta_key' => $meta_keys[0],
    'orderby' => 'meta_value',
    'posts_per_page' => -1);
$my_query = new WP_Query($args);

And then later on, ends with…

usort($my_query->posts, 'sort_3_keys');
while ( $my_query->have_posts() ) : $my_query->the_post();
$id = $post->ID;
$storestate = $id_array[$id][$meta_keys[0]];
$storecity = $id_array[$id][$meta_keys[1]];
$storename = $id_array[$id][$meta_keys[2]];
echo "$storestate | $storecity | $storename <br />";
endwhile;

In summary, the cat who developed this code (http://wordpress.mcdspot.com/2012/10/24/sort-posts-on-multiple-custom-fields/), is one bad muthah and I’m grateful for his work and for him sharing it. This has helped me achieve the results I needed. Cheers.