Hello I kind of need help with my sorting I want to create a shopping list and sort it alphabetically but I cant seem to make it work, can someone out there pls help me because I really want to do this, the code is down below attached.
P.S Does anyone like my name???
Also if you have something mean to say don’t pls because it is really mean and makes me upset.
Ariyan.mz
While I don’t mind helping people out, please, please, oh please, try to google the answer for yourself first.
You’ll find your answer here: https://forums.coronalabs.com/topic/36656-help-sort-table-alphabetically/
It was the first result from Google with the search term: “lua sort alphabetically”.
Hi @m.davasaz or @Ariyan.zm, and welcome to the Corona Labs community forum.
While no one here wants to be mean to you, there are certain expectations that everyone has to abide by for us to have a successful community. Please take a moment and make sure you read our Forum Rules: https://coronalabs.com/forum-rules/
Secondly, we operate on a basic principle of “Help us help you”. Your question above is way to generic for anyone to really answer you. Community member @roaminggamer wrote a great post about how ask better questions to get better answers here: https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/
I highly recommend you read that post after you read the forum rules.
Then regarding people being mean to you: when you join an Internet community, you’re reading text written by other people which can easily have intent and emotion mis-interperated. So what you might feel is mean to you may not have been intended that way. Try to make the best use of information provided without letting your emotions or the perceived emotions of the person get in the way.
I hope you have great success here and get the information you’re looking for.
Rob
I’m with Xedur on that one and would also go a little further and ask the user to check out the well written documentation.
I dont get then name thing or understand where the mean comment comes from.
It’s after all the first post of the user so no idea whats going on there.
The mean comment might originate from me including the let me Google that for you link. 
While did not, and do not, want to be mean, I see plenty of questions posted here that would have been solved by either opening Corona’s documentation, lua’s documentation or by inserting the question into Google, like with this one.
For what its worth, I’m unable to find any mean comments in your post, so let’s assume its a missunderstanding 
@m.davasaz,
Hi. If you have a list (table) like this:
local shoppingList = { "eggs", "beer", "ham", "milk" }
Sorting can be done like this:
table.sort( shoppingList )
However, I suspect you have something more like this:
local shoppingList = { { item = "eggs", price = "1.99" }, { item = "beer", price = "6.99" }, { item = "ham", price = "4.99" }, { item = "milk", price = "2.99" }, }
So, how do you sort this?
You need to reach in and sort on ‘item’. This is how:
local function itemSort( a, b ) return a.item \< b.item -- I may have this flipped; you may need \> instead end table.sort( shoppingList, itemSort )
Essentially, I wrote a custom sort function that table.sort() then used to sort on the sub-table item values.
if you want to create a shopping list, the obvious answer is going for a sqlite database and insert the items on a proper table for that.
the advantages are that you can have access to those items even if the app is closed and you open it again.
you can add, favorites items, save for later, etc. Sorting tables in sqlite are pretty easy, so your problem is kinda resolved automatic.
There’s an tutorial here:
https://docs.coronalabs.com/tutorial/data/databaseAccess/index.html
or here:
if you want eat popcorns while learning just see the video (theres more videos from there):
https://www.youtube.com/watch?v=QsWp54j4-sU
Your shopping system not only the list, should be build in sqlite if you ask me.
Even better on a remote server (cloud or mysql/php or anything your want) so you can update/add/remove items without updating the app and you can access favorits/shopping list on any device.
If you don’t know nothing of this, just take your time. Uploading an useless app to google store or apple store is even worst.
Thanks everyone for this i searched it up on google but i couldnt find it, anyway people have been mean to me on other forum things and it really makes me upset so i was just saying so i dont get upset i really apreciate the help
While I don’t mind helping people out, please, please, oh please, try to google the answer for yourself first.
You’ll find your answer here: https://forums.coronalabs.com/topic/36656-help-sort-table-alphabetically/
It was the first result from Google with the search term: “lua sort alphabetically”.
Hi @m.davasaz or @Ariyan.zm, and welcome to the Corona Labs community forum.
While no one here wants to be mean to you, there are certain expectations that everyone has to abide by for us to have a successful community. Please take a moment and make sure you read our Forum Rules: https://coronalabs.com/forum-rules/
Secondly, we operate on a basic principle of “Help us help you”. Your question above is way to generic for anyone to really answer you. Community member @roaminggamer wrote a great post about how ask better questions to get better answers here: https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/
I highly recommend you read that post after you read the forum rules.
Then regarding people being mean to you: when you join an Internet community, you’re reading text written by other people which can easily have intent and emotion mis-interperated. So what you might feel is mean to you may not have been intended that way. Try to make the best use of information provided without letting your emotions or the perceived emotions of the person get in the way.
I hope you have great success here and get the information you’re looking for.
Rob
I’m with Xedur on that one and would also go a little further and ask the user to check out the well written documentation.
I dont get then name thing or understand where the mean comment comes from.
It’s after all the first post of the user so no idea whats going on there.
The mean comment might originate from me including the let me Google that for you link. 
While did not, and do not, want to be mean, I see plenty of questions posted here that would have been solved by either opening Corona’s documentation, lua’s documentation or by inserting the question into Google, like with this one.
For what its worth, I’m unable to find any mean comments in your post, so let’s assume its a missunderstanding 
@m.davasaz,
Hi. If you have a list (table) like this:
local shoppingList = { "eggs", "beer", "ham", "milk" }
Sorting can be done like this:
table.sort( shoppingList )
However, I suspect you have something more like this:
local shoppingList = { { item = "eggs", price = "1.99" }, { item = "beer", price = "6.99" }, { item = "ham", price = "4.99" }, { item = "milk", price = "2.99" }, }
So, how do you sort this?
You need to reach in and sort on ‘item’. This is how:
local function itemSort( a, b ) return a.item \< b.item -- I may have this flipped; you may need \> instead end table.sort( shoppingList, itemSort )
Essentially, I wrote a custom sort function that table.sort() then used to sort on the sub-table item values.
if you want to create a shopping list, the obvious answer is going for a sqlite database and insert the items on a proper table for that.
the advantages are that you can have access to those items even if the app is closed and you open it again.
you can add, favorites items, save for later, etc. Sorting tables in sqlite are pretty easy, so your problem is kinda resolved automatic.
There’s an tutorial here:
https://docs.coronalabs.com/tutorial/data/databaseAccess/index.html
or here:
if you want eat popcorns while learning just see the video (theres more videos from there):
https://www.youtube.com/watch?v=QsWp54j4-sU
Your shopping system not only the list, should be build in sqlite if you ask me.
Even better on a remote server (cloud or mysql/php or anything your want) so you can update/add/remove items without updating the app and you can access favorits/shopping list on any device.
If you don’t know nothing of this, just take your time. Uploading an useless app to google store or apple store is even worst.
Thanks everyone for this i searched it up on google but i couldnt find it, anyway people have been mean to me on other forum things and it really makes me upset so i was just saying so i dont get upset i really apreciate the help