 
      func numberOfSectionsInTableView(tableView: UITableView) -> Int {
         // Return the number of sections.
-        return 1
+        //return 1
+		return self.sections.count
     }
 
      func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         // Return the number of rows in the section.
-        return self.newsEntries.count
+        //return self.newsEntries.count
+		return sections[sortedSections[section]]!.count
     }
 	
      func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
+//		let cell: UITableViewCell! = tableView.dequeueReusableCellWithIdentifier(self.cellIdentifier, forIndexPath: indexPath) as! UITableViewCell
+//		
+//		// Configure the cell for this indexPath
+//		cell.textLabel!.text = (newsEntries.objectAtIndex(indexPath.row) as! NewsEntry).title
+//		cell.detailTextLabel?.text = (newsEntries.objectAtIndex(indexPath.row) as! NewsEntry).section
+//			// + ", " + (newsEntries.objectAtIndex(indexPath.row) as! NewsEntry).shortDescription!
+//		//cell.detailTextLabel!.lineBreakMode = .ByWordWrapping;
+//		cell.detailTextLabel!.numberOfLines = 2; // Show 2 lines
+		
 		let cell: UITableViewCell! = tableView.dequeueReusableCellWithIdentifier(self.cellIdentifier, forIndexPath: indexPath) as! UITableViewCell
-		
-		// Configure the cell for this indexPath
-		cell.textLabel!.text = (newsEntries.objectAtIndex(indexPath.row) as! NewsEntry).title
-		cell.detailTextLabel?.text = (newsEntries.objectAtIndex(indexPath.row) as! NewsEntry).shortDescription
-		//cell.detailTextLabel!.lineBreakMode = .ByWordWrapping;
-		cell.detailTextLabel!.numberOfLines = 2; // Show 2 lines
-
+
+		let tableSection = sections[sortedSections[indexPath.section]]
+		let tableItem = tableSection![indexPath.row]
+
+		cell.textLabel!.text = tableItem.title
+		cell.detailTextLabel?.text = tableItem.shortDescription
+		cell.detailTextLabel?.numberOfLines = 2; // Show 2 lines
+		
 		return cell
     }
+	
+	func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
+		return sortedSections[section]
+	}
 	
     func getHighFiJSON(whichFeed : String){
         println("getHighFiJSON: \(whichFeed)")

							//	let articleID: Int
							//	let sourceID: Int
							//	let highlight: Bool
						)
					}
					println("entries: \(entries.count)")
					
					dispatch_async(dispatch_get_main_queue()) {
						self.newsEntries.addObjectsFromArray(entries)
						self.tableView!.reloadData()
						self.refreshControl?.endRefreshing()
						return

		}
	}
	
	func getTimeSince(item: String) -> String {
		//println("getTimeSince: \(item)")
		if let startDate = dateFormatter.dateFromString(item) {
		//if let startDate = dateFormatter.dateFromString("2015-06-18T9:46:08.000Z") {
			let components = calendar.components(
				NSCalendarUnit.CalendarUnitDay | NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute, fromDate: startDate, toDate: NSDate(), options: nil)
			let days = components.day
			let hours = components.hour
			let minutes = components.minute
			//println("\(days) days, \(hours) hours, \(minutes) minutes")
			
			if days == 0 {
				if hours == 0 {
					if minutes < 0 { return "Juuri nyt" }
					else if minutes < 5 { return "< 5 minuuttia" }
					else if minutes < 15 { return "< 15 minuuttia" }
					else if minutes < 30 { return "< 30 minuuttia" }
					else if minutes < 45 { return "< 45 minuuttia" }
					else if minutes < 60 { return "< tunti" }
				} else {
					if hours < 24 { return "\(hours) tuntia" }
				}
			} else {
				if days == 1 {
					return "Eilen"
				} else {
					return "\(days) päivää"
				}
			}
		}
		
		return "0"
	}
	
	override func didReceiveMemoryWarning() {
		super.didReceiveMemoryWarning()
		// Dispose of any resources that can be recreated.
