Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

where to see all about sorts?  RSS feed

 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want all the codes ''together'' if there are about sorts.I want search an array by String,by int ,or by double .Any link where i could read?
 
Paweł Baczyński
Bartender
Posts: 2054
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain what do you mean.
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paweł Baczyński wrote:Please explain what do you mean.
all sorts (like bubblesort).There is a site who have them all in one ?(and i dont search only for integer,i want string and double ).I mean sort an array by string etc
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
 
Carey Brown
Bartender
Posts: 2992
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Collections.sort(), mylist.sort(), or Arrays.sort(). They default to giving you the "natural" sort order, e.g. alphabetically for Strings. You can customize the sort order by creating your own class that implements Comparator. With Comparator you can sort by multiple fields of varying types.
 
Campbell Ritchie
Marshal
Posts: 55682
162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for delay in replying. If you search for “sorting algorithms”, you will get many hits. This is one which I think will be helpful. You also asked about searching, so try here.
 
Tim Holloway
Bartender
Posts: 18705
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The seminal work on sorts and searches is Donald Knuth's The Art of Computer Programming. Volume 3, Sorting and Searching.

The code presented there is not ready-to-run. In attempt to be language/platform neutral, Knuth invented his own programming language, designed to be run in a language virtual machine (like Java), but this was done back in the days when assembly language was the thing.

However, the important thing about Knuth isn't the code examples, it's the analysis that goes with it. He didn't invent the algorithms he describes, but he does explain what makes them tick.

Whenever people create a new language environment, their primary resource on whatever built-in sort and search functions they may provide is often this book or something ultimately derived from it. I've seen it in Fortran, I've seen it in Java, and I assume that many other platforms I've worked with over the years hearken back to those underpinnings. Whatever additional features you may find, there's almost always Knuth at the bottom.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!