Is there any way to write more generic code in below code?

Is there any way to write more generic code in below code?

Hello All, 

I recently started coding. Please help me to write more generic way of writing below code. 

  1. function set_selection(elem)
  2. {
  3. switch(elem.id){
  4. case "div_SortCost" :
  5. if(elem.id == "div_SortCost")
  6. {
  7. if(btnSortNumber.elem !=null)
  8. {
  9. btnSortNumber.disactivateSelection();
  10. }
  11. if(btnSortCost.elem!=null)
  12. {
  13. btnSortCost.activateSelection();
  14. }
  15. if(btnSortHour.elem!=null)
  16. {
  17. btnSortHour.disactivateSelection();
  18. }
  19. }
  20. break;
  21. case "div_SortHour":
  22. if(btnSortNumber.elem!=null)
  23. {
  24. btnSortNumber.disactivateSelection();
  25. }
  26. if(btnSortCost.elem!=null)
  27. {
  28. btnSortCost.disactivateSelection();
  29. }
  30. if(btnSortHour.elem!=null)
  31. {
  32. btnSortHour.activateSelection();
  33. }
  34. break;
  35. case "div_SortNumber":
  36. if(btnSortNumber.elem!=null)
  37. {
  38. btnSortNumber.activateSelection();
  39. }
  40. if(btnSortHour.elem!=null)
  41. {
  42. btnSortHour.disactivateSelection();
  43. }
  44. if(btnSortCost.elem!=null)
  45. {
  46. btnSortCost.disactivateSelection();
  47. }
  48. break;
  49. }
  50. }

Thanks
Chandu