Hi,
Use ORDER BY:
http://www.w3schools.com/sql/sql_orderby.asp[
^]
For example:
String strSQL;
strSQL = "SELECT * FROM nametable WHERE userID=idname ORDER BY taskname ASC";
[EDIT after reading your comment]
Updated version of code block
String strSQL;
strSQL = "SELECT * FROM nametable WHERE userID='" + idname + "'";