Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
164 user(s) are online (136 user(s) are browsing Forums)

Members: 0
Guests: 164

more...

Support us!

Headlines

 
  Register To Post  

Sorting a list
Home away from home
Home away from home


See User information
I'm having some difficulties trying to sort a struct list. The plan was, when a new item is added by the user that will go into the listbrowser. I'd like to sort it before i put it in the listbrowser. So the listbrowser is always in alphabetical order. Anyone have an good idea/example on how to archieve this?

AMybe not the best descrition,but i hope it was clear enough.

X5000
Go to top
Re: Sorting a list
Supreme Council
Supreme Council


See User information
@Antique

You could set the ln_Pri field of the list node to the ASCII value of the first character, and then use Enqueue() to add the node to the list.

Failing that, you could add the list back with SetAttrs(), call the LBM_SORT method, then refresh the gadget.

Simon

Comments made in any post are personal opinion, and are in no-way representative of any commercial entity unless specifically stated as such.
----
http://codebench.co.uk
Go to top
Re: Sorting a list
Amigans Defender
Amigans Defender


See User information
@Antique

Quote:

Rigo wrote:
You could set the ln_Pri field of the list node to the ASCII value of the first character, and then use Enqueue() to add the node to the list.

That will, however, only work if you don't use strings with a character set other than ASCII.

The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top
Re: Sorting a list
Just popping in
Just popping in


See User information
@Antique

Take a look at YAM's source: http://trac.yam.ch/browser/trunk/src/MailList.c

The SortMailList() function will do exactly what you want. You just have to provide a suitable comparison function.

Go to top
Re: Sorting a list
Home away from home
Home away from home


See User information
@Antique

I got the sorting to work. But i have a small issue. There are 3 columns in the lister,but i only want to sort the last 2. The first one is just an entry counter,and should stay unsorted. Is this possible?

X5000
Go to top
Re: Sorting a list
Not too shy to talk
Not too shy to talk


See User information
@Antique

You can retrieve the contents of each column with the GetListBrowserNodeAttrs function. Use this in your comparison routine.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project