private Group [ ] orderGroup ( List < Group > groups , String [ ] groupsOrder ) { LinkedList < Group > groupsOrdered = new LinkedList ( ) ; List < Group > remained = new ArrayList ( groups ) ; for ( String order : groupsOrder ) { for ( Group remain : remained ) { if ( remain . title . equals ( order ) ) { groupsOrdered . add ( remain ) ; remained . remove ( remain ) ; break ; } } } groupsOrdered . addAll ( remained ) ; return groupsOrdered . toArray ( new Group [ groupsOrdered . size ( ) ] ) ; }
Order groups based on passed order .