Jump to content




Sorting Problems


  • You cannot reply to this topic
4 replies to this topic

#1 Evil_Bengt

  • Members
  • 24 posts

Posted 03 October 2014 - 06:35 AM

I'm having real problems with sorting numbers and stuff with lua... Is there any way to like sort 4 numbers that is in the same variable from highest to lowest... Like 9826 to 9862 and vice versa? :D

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 03 October 2014 - 06:44 AM

Can we see the code that you've tried so far, and what these 'real problems' are that you've been having with them? that way we can give you better advice for your specific problem.

#3 Evil_Bengt

  • Members
  • 24 posts

Posted 03 October 2014 - 01:49 PM

I haven't really started on anything with that yet... It's just a fun idea I got from this vid:

https://www.youtube....h?v=d8TRcZklX_Q

I thought that I could make some fun generator with this to test numbers...
To do that one have to sort the numbers in falling order and subtract the opposite, like this example:

input: 6548
computation: 8654 - 4568

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 03 October 2014 - 01:52 PM

okay, well you'll want to take a look into tables. you can then make use of the table.sort function which will sort the values within the table

#5 Evil_Bengt

  • Members
  • 24 posts

Posted 03 October 2014 - 10:06 PM

Nice, I've been reading the online lua book thingy and when you say it, I remember that I've read about that sort function! Thanks alot!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users