this is the program of student list using stl finding maximum,min marks nd sorting on basis of ID ..max min are working fine but error ocuurs when i add aort.. plz someone help...
thanks ur solution works fine but wat do u mean by random access iteraotrs , if i use the same code with vectors instead of list the template function sort is working fine please explain ??
Random access just means that you can access any element at an arbitrary position in equal time. std::list is a linked list so if we want to find an element at an specific position we need to step through each element until we reach the element we want, so list is not a random access container.
Random access iterators have some extra operations that is needed in std::sort. It would possible to implement these extra operations for the list iterators as well but then it would be very slow and std::sort on a std::list would be terrible slow. Instead it's much better to use a special sorting algorithm that is better suited for linked lists, and that's what std::list::sort is.