Hello Richard
Downloadable working snippets on my website:
https://www.professorcad.co.uk/appinventorsnippets#SortListViewItems
Hello Richard
Downloadable working snippets on my website:
https://www.professorcad.co.uk/appinventorsnippets#SortListViewItems
Chris,
Thanks for the quick reply. I had looked at that earlier, didn't try to run it. I just tried and it says "Webpage not available"
Is it not possible to simply sort the list I already have without using a web viewer? Seems overly complicated.
I think the extension I have is supposed to do that. I just haven't figured out where and how to instruct it.
Timai2,
I'm trying to use the extension you listed in #3 I guess I don't know what the name of the list is. The list is song titles would I have to rename everything to include a number?
The ListUtils extension will only sort numbers, so you may be better off using Saj's bubble sort
Here is a procedure I have made from that, you can then choose whether to sort numbers or text.
You should be able to drag these blocks onto your blocks editor
You could also try this extension, which should handle text:
Also, remember, if you have two lists that are related to each other by index (e.g. item3 in list1 and item3 in list2 "go together"), and you sort one list, the indexes will no longer relate to each other.
I have that extension, guilty of not taking a closer look at the screen shot to see what the different sorts were.
Doesn't bubble sort end up being slow it there were say 100 names and with a long the name get even slower? Does it play nice with spaces in the names?
Not done any speed tests on large lists or lists with long strings in them
Please remove any spaces from your file and directory names, this is not good practice.
###############################
Here is another way of using the webviewer (you need a web component as well for a couple of blocks)
The sorted list comes back as a string, so you need to convert that back to a list with the JsonTextDecode block.
I think I just found a new way of sorting a list with simple code and no extensions, with Google Apps Script.
Blocks:
Script:
function doPost(e) {
var txt = e.parameter.list;
var lst = txt.split(',');
var rslt = lst.sort();
return ContentService.createTextOutput(String(rslt));
}
Screenshot:
Yes, I have earlier noticed this issue. I tried some Java methods too. Seems that the JS method likes to put numbers after letters in alphabetical order.
It's simply a fast and simple JavaScript function run in a WebView Component (no internet required and the component can be 1px x 1px).
The Web Page is available, just tested in FireFox and Chrome - but if the link fails in your neck of the woods, go to my home page and navigate from there.
My opinion is that if the Extension does something that App Inventor cannot, that's great, use it - but otherwise stick with coding. Many extensions may not be maintained by their Developers, so there is a risk that an extension can become incompatible with future releases of Android and App Inventor.
soyouare
sayingimust
renameall
ofmymusic
filestothis
reallyhardtoread
formatquestionmark
Instead of this
much easier
to read list
Even with no
punctuation this
is easier
That seems really bad, hard to implement, and hard to pick from a list for anyone who might want to use an app. My generation values real words, spelling and punctuation.
Use_an_underscore_to_replace_a_space
Your web page is available. I get that message when I run your demo aia on my tablet. Could that be an Android version 11 problem? I tried giving permission in the app but, didn't change anything.
I could batch do that with an app. Most end users would not have the knowledge or desire to do that. It would still make the list that they pick from look odd.
You can always present a list without the underscores using a replacement block:
The replacement is a space " ", not an empty text block, except for the .mp3
replacement.
Anke, again many thanks Some quick tests, didn't seem to work using it on start. Adding a button works with two different sort extensions. I was hoping to not use a button but, thinking on it I should be able to use that button to sort the list both directions.
Well, I spoke too soon. The list does change to the correct order. Before the sort fifth song on the list is "All Over Again" that is what plays. After the sort fifth song on the list is "All My Xs Live in Texas" but song that plays is "All Over Again". Similar results for all songs.
Song that is played is still in original order starting at top, no matter what the list says.
Did you heed my warning?
I saw it, didn't register. Any way around it?